'Titanic module - Average age of those who did survive, didn't survive grouped by sex
Average age of those who did survive, didn't survive grouped by sex Using Groupby
filtered survived, filtered age mean and filtered sex but how do i group 2 or more columns with 2 or more filters together using groupby
should i use .agg? how should i group the columns?
Solution 1:[1]
This should works:
data.groupby(['is_survived', 'gender']).age.mean()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Volodymyr Rudyi |
