Skip to content

Commit 0a28802

Browse files
committed
fix: assign a df and show the first 2 rows
1 parent 1ae1bd2 commit 0a28802

File tree

5 files changed

+36
-43
lines changed

5 files changed

+36
-43
lines changed

bigframes/session/__init__.py

+10-17
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ def read_gbq_query(
349349
350350
Preserve ordering in a query input.
351351
352-
>>> bpd.read_gbq_query('''
352+
>>> df = bpd.read_gbq_query('''
353353
... SELECT
354354
... -- Instead of an ORDER BY clause on the query, use
355355
... -- ROW_NUMBER() to create an ordered DataFrame.
@@ -362,16 +362,14 @@ def read_gbq_query(
362362
... FROM `bigquery-public-data.baseball.games_wide`
363363
... WHERE year = 2016
364364
... GROUP BY pitcherFirstName, pitcherLastName
365-
... ''', index_col="rowindex").head(n=5)
365+
... ''', index_col="rowindex")
366+
>>> df.head(2)
366367
pitcherFirstName pitcherLastName averagePitchSpeed
367368
rowindex
368369
1 Albertin Chapman 96.514113
369370
2 Zachary Britton 94.591039
370-
3 Trevor Rosenthal 94.213953
371-
4 Jose Torres 94.103448
372-
5 Tayron Guerrero 93.863636
373371
<BLANKLINE>
374-
[5 rows x 3 columns]
372+
[2 rows x 3 columns]
375373
376374
See also: :meth:`Session.read_gbq`.
377375
"""
@@ -441,22 +439,17 @@ def read_gbq_table(
441439
>>> import bigframes.pandas as bpd
442440
>>> bpd.options.display.progress_bar = None
443441
444-
>>> bpd.read_gbq_table("bigquery-public-data.ml_datasets.penguins").head(5)
442+
>>> df = bpd.read_gbq_table("bigquery-public-data.ml_datasets.penguins")
443+
>>> df.head(2)
445444
species island culmen_length_mm \\
446445
0 Adelie Penguin (Pygoscelis adeliae) Dream 36.6
447446
1 Adelie Penguin (Pygoscelis adeliae) Dream 39.8
448-
2 Adelie Penguin (Pygoscelis adeliae) Dream 40.9
449-
3 Chinstrap penguin (Pygoscelis antarctica) Dream 46.5
450-
4 Adelie Penguin (Pygoscelis adeliae) Dream 37.3
451447
<BLANKLINE>
452448
culmen_depth_mm flipper_length_mm body_mass_g sex
453449
0 18.4 184.0 3475.0 FEMALE
454450
1 19.1 184.0 4650.0 MALE
455-
2 18.9 184.0 3900.0 MALE
456-
3 17.9 192.0 3500.0 FEMALE
457-
4 16.8 192.0 3000.0 FEMALE
458451
<BLANKLINE>
459-
[5 rows x 7 columns]
452+
[2 rows x 7 columns]
460453
461454
See also: :meth:`Session.read_gbq`.
462455
"""
@@ -851,8 +844,7 @@ def read_gbq_model(self, model_name: str):
851844
>>> bpd.options.display.progress_bar = None
852845
853846
>>> model_name = "bigframes-dev.bqml_tutorial.penguins_model"
854-
>>> bpd.read_gbq_model(model_name)
855-
LinearRegression(optimize_strategy='NORMAL_EQUATION')
847+
>>> model = bpd.read_gbq_model(model_name)
856848
857849
Args:
858850
model_name (str):
@@ -885,7 +877,8 @@ def read_pandas(self, pandas_dataframe: pandas.DataFrame) -> dataframe.DataFrame
885877
886878
>>> d = {'col1': [1, 2], 'col2': [3, 4]}
887879
>>> pandas_df = pd.DataFrame(data=d)
888-
>>> bpd.read_pandas(pandas_df)
880+
>>> df = bpd.read_pandas(pandas_df)
881+
>>> df
889882
col1 col2
890883
0 1 3
891884
1 2 4

third_party/bigframes_vendored/pandas/io/gbq.py

+7-14
Original file line numberDiff line numberDiff line change
@@ -44,26 +44,21 @@ def read_gbq(
4444
4545
If the input is a table ID:
4646
47-
>>> bpd.read_gbq("bigquery-public-data.ml_datasets.penguins").head(5)
47+
>>> df = bpd.read_gbq("bigquery-public-data.ml_datasets.penguins")
48+
>>> df.head(2)
4849
species island culmen_length_mm \\
4950
0 Adelie Penguin (Pygoscelis adeliae) Dream 36.6
5051
1 Adelie Penguin (Pygoscelis adeliae) Dream 39.8
51-
2 Adelie Penguin (Pygoscelis adeliae) Dream 40.9
52-
3 Chinstrap penguin (Pygoscelis antarctica) Dream 46.5
53-
4 Adelie Penguin (Pygoscelis adeliae) Dream 37.3
5452
<BLANKLINE>
5553
culmen_depth_mm flipper_length_mm body_mass_g sex
5654
0 18.4 184.0 3475.0 FEMALE
5755
1 19.1 184.0 4650.0 MALE
58-
2 18.9 184.0 3900.0 MALE
59-
3 17.9 192.0 3500.0 FEMALE
60-
4 16.8 192.0 3000.0 FEMALE
6156
<BLANKLINE>
62-
[5 rows x 7 columns]
57+
[2 rows x 7 columns]
6358
6459
Preserve ordering in a query input.
6560
66-
>>> bpd.read_gbq('''
61+
>>> df = bpd.read_gbq('''
6762
... SELECT
6863
... -- Instead of an ORDER BY clause on the query, use
6964
... -- ROW_NUMBER() to create an ordered DataFrame.
@@ -76,16 +71,14 @@ def read_gbq(
7671
... FROM `bigquery-public-data.baseball.games_wide`
7772
... WHERE year = 2016
7873
... GROUP BY pitcherFirstName, pitcherLastName
79-
... ''', index_col="rowindex").head(n=5)
74+
... ''', index_col="rowindex")
75+
>>> df.head(2)
8076
pitcherFirstName pitcherLastName averagePitchSpeed
8177
rowindex
8278
1 Albertin Chapman 96.514113
8379
2 Zachary Britton 94.591039
84-
3 Trevor Rosenthal 94.213953
85-
4 Jose Torres 94.103448
86-
5 Tayron Guerrero 93.863636
8780
<BLANKLINE>
88-
[5 rows x 3 columns]
81+
[2 rows x 3 columns]
8982
9083
Args:
9184
query (str):

third_party/bigframes_vendored/pandas/io/parquet.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,14 @@ def read_parquet(
2222
>>> import bigframes.pandas as bpd
2323
>>> bpd.options.display.progress_bar = None
2424
25-
>>> gcs_path = "gs://bigframes-dev-testing/bigframes_test.parquet"
25+
>>> gcs_path = "gs://cloud-samples-data/bigquery/us-states/us-states.parquet"
2626
>>> df = bpd.read_parquet(path=gcs_path)
27+
>>> df.head(2)
28+
name post_abbr
29+
0 Alabama AL
30+
1 Alaska AK
31+
<BLANKLINE>
32+
[2 rows x 2 columns]
2733
2834
Args:
2935
path (str):

third_party/bigframes_vendored/pandas/io/parsers/readers.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ def read_csv(
6262
6363
>>> gcs_path = ("gs://bigquery-public-data-ml-datasets/holidays_and_events_for_forecasting.csv")
6464
>>> df = bpd.read_csv(filepath_or_buffer=gcs_path)
65+
>>> df.head(2)
66+
region holiday_name primary_date preholiday_days postholiday_days
67+
0 AU AUNZ_AnzacDay 2000-04-25 1 1
68+
1 AU AUNZ_AnzacDay 2001-04-25 1 1
69+
<BLANKLINE>
70+
[2 rows x 5 columns]
6571
6672
Args:
6773
filepath_or_buffer (str):
@@ -160,13 +166,13 @@ def read_json(
160166
>>> bpd.options.display.progress_bar = None
161167
162168
>>> gcs_path = "gs://bigframes-dev-testing/sample1.json"
163-
>>> bpd.read_json(path_or_buf=gcs_path, lines=True, orient="records").head(n=5)
169+
>>> df = bpd.read_json(path_or_buf=gcs_path, lines=True, orient="records")
170+
>>> df.head(2)
164171
id name
165172
0 1 Alice
166173
1 2 Bob
167-
2 3 Carol
168174
<BLANKLINE>
169-
[3 rows x 2 columns]
175+
[2 rows x 2 columns]
170176
171177
Args:
172178
path_or_buf (a valid JSON str, path object or file-like object):

third_party/bigframes_vendored/pandas/io/pickle.py

+3-8
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,17 @@ def read_pickle(
3131
>>> bpd.options.display.progress_bar = None
3232
3333
>>> gcs_path = "gs://bigframes-dev-testing/test_pickle.pkl"
34-
>>> bpd.read_pickle(filepath_or_buffer=gcs_path).head(5)
34+
>>> df = bpd.read_pickle(filepath_or_buffer=gcs_path)
35+
>>> df.head(2)
3536
species island culmen_length_mm \\
3637
0 Adelie Penguin (Pygoscelis adeliae) Dream 36.6
3738
1 Adelie Penguin (Pygoscelis adeliae) Dream 39.8
38-
2 Adelie Penguin (Pygoscelis adeliae) Dream 40.9
39-
3 Chinstrap penguin (Pygoscelis antarctica) Dream 46.5
40-
4 Adelie Penguin (Pygoscelis adeliae) Dream 37.3
4139
<BLANKLINE>
4240
culmen_depth_mm flipper_length_mm body_mass_g sex
4341
0 18.4 184.0 3475.0 FEMALE
4442
1 19.1 184.0 4650.0 MALE
45-
2 18.9 184.0 3900.0 MALE
46-
3 17.9 192.0 3500.0 FEMALE
47-
4 16.8 192.0 3000.0 FEMALE
4843
<BLANKLINE>
49-
[5 rows x 7 columns]
44+
[2 rows x 7 columns]
5045
5146
Args:
5247
filepath_or_buffer (str, path object, or file-like object):

0 commit comments

Comments
 (0)