in a a pandas df (data from a csv file) I am trying to add new columns (ratios) by dividing each column by every other column.
So far I am stuck in the process of dividing all columns by the first one (hoping to iterate the process later).
ratio_df = df.join(df.div(df['Hv10'], axis=0), rsuffix='_new_ratio')
I am getting this code from a post that deals with a similar problem.
pandas dataframe create new columns and fill with calculated values from same df
I am getting the following error message:
ValueError: operands could not be broadcast together with shapes (235170,) (3618,)
I am not sure why I am getting this error message since I am dividing each column by another (so dimension should be the same)
What am I doing wrong?
Is there a one step process to generate all these new ratio columns?
I hope my description is clear.
Thanks!