everyone. I tried this method Can I use a specific element inside the groupby functions instead of using column name?
but i gor error.
So I need to calculate the population mean next to the 'Hispanic or Latino label within this dataframe. How do I select exactly the population values for "Hispanic or Latino" and calculate the mean for them?
kind_of_pop_df = pd.DataFrame(data=pop_list_us, columns=["Year", "Ethnicity", "Hispanic Population"])
kind_of_pop_df.head(7)
kind_of_pop_df.set_index("Year",inplace=True)
print(kind_of_pop_df)
Ethnicity Hispanic Population
Year
2019 Not Hispanic or Latino 10710524
2019 Hispanic or Latino 1583156
2019 Not Hispanic or Latino 2763709
2019 Hispanic or Latino 320595
2019 Not Hispanic or Latino 42268
... ... ...
2013 Hispanic or Latino 2791
2013 Not Hispanic or Latino 105872
2013 Hispanic or Latino 1567526
2013 Not Hispanic or Latino 323451
2013 Hispanic or Latino 241243
[98 rows x 2 columns]
Can you answer with specific answers? Thanks!