We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
main
https://pandas.pydata.org/docs/dev/getting_started/intro_tutorials/07_reshape_table_layout.html
If you run this line discussing the connection between pivot tables and groupby(),
groupby()
air_quality.groupby(["parameter", "location"]).mean()
you actually get TypeErrors related to string conversions and the aggregation function failing.
Restricting to numeric values only shows the intended result that matches the pivot table. I.e.,
print(air_quality.pivot_table( values="value", index="location", columns="parameter", aggfunc="mean", margins=True )) print(air_quality.groupby(["parameter", "location"]).mean(numeric_only=True))
shows
parameter no2 pm25 All location BETR801 26.950920 23.169492 24.982353 FR04014 29.374284 NaN 29.374284 London Westminster 29.740050 13.443568 21.491708 All 29.430316 14.386849 24.222743 value parameter location no2 BETR801 26.950920 FR04014 29.374284 London Westminster 29.740050 pm25 BETR801 23.169492 London Westminster 13.443568
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Pandas version checks
main
hereLocation of the documentation
https://pandas.pydata.org/docs/dev/getting_started/intro_tutorials/07_reshape_table_layout.html
Documentation problem
If you run this line discussing the connection between pivot tables and
groupby()
,you actually get TypeErrors related to string conversions and the aggregation function failing.
Suggested fix for documentation
Restricting to numeric values only shows the intended result that matches the pivot table. I.e.,
shows
The text was updated successfully, but these errors were encountered: