본문 바로가기
Kaggle Learn

Pandas - Summary Functions and Maps

by 가으더 2024. 3. 20.
728x90

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

 

Summary Functions and Maps

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

www.kaggle.com

Summary functions

pandas는 'summary functions'을 제공한다.

describe() : 해당 열의 요약(count, mean, unique...)

reviews.points.describe()
count    129971.000000
mean         88.447138
             ...      
75%          91.000000
max         100.000000
Name: points, Length: 8, dtype: float64

 

reviews.points.mean() : 88.44...

reviews.taster_name.unique() : 한번 이상 등장한 애들의 배열

reviews.taster_name.value_counts() : 각 value 들의 등장 횟수

Maps

한 집합을 다른 집합으로 바꾸는 것.

review_points_mean = reviews.points.mean()
reviews.points.map(lambda p: p - review_points_mean)
0        -1.447138
1        -1.447138
            ...   
129969    1.552862
129970    1.552862
Name: points, Length: 129971, dtype: float64

map()은 새로운 Series를 반환한다.