Note
Pandas (38) 본문
728x90
How to extract the row and column number of a particular cell with given criterion?
# Input
df = pd.read_csv('https://raw.githubusercontent.com/selva86/datasets/master/Cars93_miss.csv')
# Solution
# Get Manufacturer with highest price
df.loc[df.Price == np.max(df.Price), ['Manufacturer', 'Model', 'Type']]
# Get Row and Column number
row, col = np.where(df.values == np.max(df.Price))
# Get the value
df.iat[row[0], col[0]]
df.iloc[row[0], col[0]]
# Alternates
df.at[row[0], 'Price']
df.get_value(row[0], 'Price')
# output
61.899999999999999
'Pandas' 카테고리의 다른 글
Pandas (40) (0) | 2022.09.03 |
---|---|
Pandas (39) (0) | 2022.08.31 |
Pandas (37) (0) | 2022.08.29 |
Pandas (36) (0) | 2022.08.28 |
Pandas (35) (0) | 2022.08.27 |
Comments