Skip to content

Tag: pandas

Splitting object data into new columns in dataframe

i have a dataframe with column business_id and attributes with thousands of rows like this: how do create new column for each attribute with the value to the business id ? and if it’s not applicable to that business id, it will specify false. example: while also noting that there are some attributes wit…

Retain strings in a column using a dictionary’s value

I want to retain the string with the largest value based on a dictionary’s key and value. Any suggestion to how to do it effectively? Expected output: Answer One way it to use apply with max and fruit_dict.get as key: or, if you expect some names to be missing from the dictionary: output:

pivot df with duplicates as new rows

Evening, I have a dataframe that I want to reshape. there are duplicate id vars for some columns, and i want the duplicate values to appear as new rows my data looks like this, and i want to have the ids as a row, with the group as column, and the choices as the values. if there are multiple choices

Replace unknown values (with different median values)

I have a particular problem, I would like to clean and prepare my data and I have a lot of unknown values for the “highpoint_metres” column of my dataframe (members). As there is no missing information for the “peak_id”, I calculated the median value of the height according to the peak…