Confused
Confused

Reputation: 353

find min and max of each column in pandas without min and max of index

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

Upvotes: 1

Views: 1307

Answers (2)

René
René

Reputation: 4827

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

Upvotes: 1

Samuel Thudi
Samuel Thudi

Reputation: 124

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:]

Upvotes: 1

Related Questions