Skip to content

Tag: pandas

How to append a dictionary with multiple keys to a dataframe

I am trying to append a dictionary to my DataFrame. This is how the DataFrame looks: And this is the dictionary: I need to append this dictionary to my df. I know how to do it when I append one column (using map) but this is not going to work here. Any ideas on how to append this? Answer You

convert multiple units to KG in pandas

let’s say i have this code(which is obviously wrong) I want to apply such condition to each value in a column(weights) based on another column(weight unit). Is there an efficient way to do it. Preferably allowing a func pass so easy to modify Answer Don’t use a function, this will be slow. numpy.v…