1. Summary functions
reviews.points.describe()
# It returns count, mean, min, 25%, 50%(median), 75%, max
describe() 함수는 주어진 columns 에 대한 기초통계량을 테이블로 보여준다.
# return mean of Series
reviews.points.mean()
# return unique values of column
reviews.taster_name.unique()
# return unique values and its count
reviews.taster_name.value_counts()
2. Maps
맵(map)이라는 함수는 말 그대로 하나의 값을 다른 값으로 매핑시키는 작업을 수행한다. 데이터 사이언스에서는 이미 존재하는 값을 이용해 새로운 값을 창출하거나 기존의 값을 변화시킬 필요가 있다.
reviews.points.map(lambda x : x - x.mean())
map()은 시리즈 객체에만 적용되는데 이는 기존의 시리즈 객체를 함수를 통해 변화시켜 새로운 시리즈로 출력한다.
apply()는 데이터 프레임을 특정한 함수를 통해 값을 변화하려고 할 때 사용한다.
def remean_points(row) :
row.points = row.points - row.mean()
return row
reviews.apply(remean_points, axis = 'columns')
Source of the course : Kaggle Course _ Summary Functions and Maps
'Course > [Kaggle] Data Science' 카테고리의 다른 글
[Python] Data Types and Missing Values (0) | 2022.02.11 |
---|---|
[Python] Grouping and Sorting (0) | 2022.02.11 |
[Python] Indexing, Selecting & Assigning (0) | 2022.02.11 |
[Python] Creating, Reading and Writing (0) | 2022.02.11 |
[Python] Working with External Libraries (0) | 2022.02.11 |