Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

docs: use head() to get top n results, not to preview results #190

New issue

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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions 13 samples/snippets/pandas_methods_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,20 @@ def test_bigquery_dataframes_pandas_methods():
bq_df = bpd.read_gbq(query_or_table)

# Inspect one of the columns (or series) of the DataFrame:
bq_df["body_mass_g"].head(10)
bq_df["body_mass_g"]

# Compute the mean of this series:
average_body_mass = bq_df["body_mass_g"].mean()
print(f"average_body_mass: {average_body_mass}")

# Calculate the mean body_mass_g by species using the groupby operation:
bq_df["body_mass_g"].groupby(by=bq_df["species"]).mean().head()
# Find the heaviest species using the groupby operation to calculate the
# mean body_mass_g:
(
bq_df["body_mass_g"]
.groupby(by=bq_df["species"])
.mean()
.sort_values(ascending=False)
.head(10)
)
# [END bigquery_dataframes_pandas_methods]
assert average_body_mass is not None
Morty Proxy This is a proxified and sanitized view of the page, visit original site.