Aggregation And Grouping
import numpy as np
import pandas as pd titanic = pd.read_csv('data/titanic.csv')
# fetching column names using .keys method
print(titanic.keys()) Index(['survived', 'pclass', 'sex', 'age', 'fare', 'embarked', 'who',
'embark_town', 'alive', 'alone'],
dtype='object')print(titanic.head()) # show the header, includes first five rows survived pclass sex age fare embarked who embark_town alive \
0 0 3 male 22.0 7.2500 S man Southampton no
1 1 1 female 38.0 71.2833 C woman Cherbourg yes
2 1 3 female 26.0 7.9250 S woman Southampton yes
3 1 1 female 35.0 53.1000 S woman Southampton yes
4 0 3 male 35.0 8.0500 S man Southampton no
alone
0 False
1 False
2 True
3 False
4 True 1. SIMPLE AGGREGATION
1.1. describe()
1.2. Fetching Unique Values
1.3. Frequency of Unique Values
2. GROUPBY: SPLIT, APPLY, COMBINE
2.1. Grouping by Single Column
a. Split
b. Apply-Combine
2.2. Grouping by two Columns
2.3. Iteration over groups
3. AGGREGATE, FILTER, TRANSFORM, APPLY
3.1. Aggregation
3.2 Filtering
3.3. Transformation
3.4. Apply
Last updated