본 내용은 인프런 강의 <데이터 분석을 위한 판다스>를 수강하며 중요한 점을 정리한 글입니다.
판다스 튜토리얼
https://pandas.pydata.org/pandas-docs/stable/getting_started/intro_tutorials/index.html
- 35세 초과인 승객 확인하기
titanic[titanic['Age'] > 35]
above_35 = titanic[titanic['Age'] > 35]
above_35.shape
->
(217, 12) # 로우 선택하기
- Pclass가 2나 3인 승객 선택하기
titanic['Pclass'].isin([2, 3])
->
0 True
1 False
2 True
3 False
4 True
...
886 True
887 False
888 True
889 False
890 True
Name: Pclass, Length: 891, dtype: bool
titanic[titanic['Pclass'].isin([2, 3])]
=
(titanic['Pclass'] == 2) | (titanic['Pclass'] == 3)
# 얘도 Pclass가 2 또는 3인 연산해주는 것
titanic[(titanic['Pclass'] == 2) & (titanic['Age'] == 30)]