Home > OS >  find min and max of each column in pandas without min and max of index
find min and max of each column in pandas without min and max of index

Time:07-14

I have a data frame as shown below.

enter image description here

I need to find the min and max of each column.The code I used is given below.

df_thd_funct_mode1_T.agg([min, max])

and the output obtained is given below.

enter image description here

You can see that the min and max of index is also came there.I don't need that.So I changed my code as shown.

df_thd_funct_mode1_T.agg([min, max],axis="columns")

but it is throwing some error as shown. May I know where I went wrong

ValueError: no results

CodePudding user response:

just select from the second column of the result and save it in a new dataframe.

df_thd_funct_mode1_T.agg([min,max]).iloc[:,1:]

to save it to a new df:

new_df = df_thd_funct_mode1_T.agg([min,max]).iloc[:,1:]

CodePudding user response:

df_thd_funct_mode1_T.set_index('index').agg([min, max])
  • Related