I'm looking for a way to get the average marital status of each age:
For example, for people who are 34 years old the median martial status is Single, for 35 it is Single also and so on.
I group the dataframe
df_edad_estado_civil.groupby(['Estado_Civil', 'Edad'], as_index=False).mean()
but it issues errors like:
DataError: No numeric types to aggregate
Basically, this is a part of my DataFrame:
Edad Estado_Civil
0 38 Soltero
1 26 Casado
2 26 Soltero
4 38 Soltero
5 24 Soltero
6 28 Soltero
7 30 Casado
8 32 Soltero
9 19 Soltero
10 28 Soltero
11 45 Casado
12 27 Soltero
13 41 Casado
14 45 Casado
15 38 Soltero
I need to get a list of a median status for every age like this:
years_old status_mediam
34 single
. .
36 single
37 married
38 married ....
45 divorced and so on.