Python - Pandas: number/index of the minimum value in the given row
问题 I have one pandas dataframe, with one row and multiple columns. I want to get the column number/index of the minimum value in the given row. The code I found was: df.columns.get_loc('colname') The above code asks for a column name. My dataframe doesn't have column names. I want to get the column location of the minimum value. 回答1: Use argmin with converting DataFrame to array by values, only necessary only numeric data: df = pd.DataFrame({ 'B':[4,5,4,5,5,4], 'C':[7,8,9,4,2,3], 'D':[1,3,5,7,1