본문 바로가기

파이썬

[판다스] df.idxmax(): 값이 가장 큰 행의 인덱스 반환

Create a variable bargain_wine / with the title of the wine / with the highest points-to-price ratio / in the dataset.

 

-> bargain_wine 이란 변수 만들기// 와인 이름이랑 // 포인트/프라이스 비율 제일 높은// 데이터 셋에서

-> 데이터셋 중에서 포인트/프라이스 비율 제일 높은 와인을 bargain_wine 이란 변수에 저장하기

 

ㅎㅎ.... 영어가 안되서 문제를 못풀어

 

풀이는! 

bargain_wine_idx = (reviews.points / reviews.price).idxmax()
bargain_wine = reviews.loc[bargain_wine_idx,'title']

 

DataFrame.idxmax() : 값이 가장 큰 행의 인덱스 반환

 


참고

https://www.kaggle.com/code/residentmario/summary-functions-and-maps/tutorial

 

Summary Functions and Maps

Explore and run machine learning code with Kaggle Notebooks | Using data from multiple data sources

www.kaggle.com