PYTHON
pandas get index of max value in column
#use this to get the index of the max value of a column
max_index = column.idxmax()
get column index of maximum value in each row pandas
>>> df.idxmax(axis=1)
0 Communications
1 Business
2 Communications
3 Communications
4 Business
dtype: object
maximum element in dataframe row
max_elements = df.max(axis = 1) #axis = 0, default, max of each column
print(max_elements)
pandas find column with max value for each row
# credit to Stack Overflow in the source link
df.head()
Communications and Search Business General Lifestyle
0 0.745763 0.050847 0.118644 0.084746
0 0.333333 0.000000 0.583333 0.083333
0 0.617021 0.042553 0.297872 0.042553
0 0.435897 0.000000 0.410256 0.153846
0 0.358974 0.076923 0.410256 0.153846
df.idxmax(axis=1)
0 Communications
1 Business
2 Communications
3 Communications
4 Business
dtype: object
pd df return index for the maximum value in each row
df.idxmax(axis="columns")
pandas df index for the maximum value in each row
pandas get index of max value in column
#use this to get the index of the max value of a column
max_index = column.idxmax()
get column index of maximum value in each row pandas
>>> df.idxmax(axis=1)
0 Communications
1 Business
2 Communications
3 Communications
4 Business
dtype: object
maximum element in dataframe row
max_elements = df.max(axis = 1) #axis = 0, default, max of each column
print(max_elements)
pandas find column with max value for each row
# credit to Stack Overflow in the source link
df.head()
Communications and Search Business General Lifestyle
0 0.745763 0.050847 0.118644 0.084746
0 0.333333 0.000000 0.583333 0.083333
0 0.617021 0.042553 0.297872 0.042553
0 0.435897 0.000000 0.410256 0.153846
0 0.358974 0.076923 0.410256 0.153846
df.idxmax(axis=1)
0 Communications
1 Business
2 Communications
3 Communications
4 Business
dtype: object
pd df return index for the maximum value in each row
df.idxmax(axis="columns")
pandas df index for the maximum value in each row