Skip to content

docs: add code samples for shape and head #257

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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 58 additions & 2 deletions third_party/bigframes_vendored/pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,17 +272,73 @@ def head(self, n: int = 5):
on position. It is useful for quickly testing if your object
has the right type of data in it.

**Not yet supported** For negative values of `n`, this function returns
For negative values of `n`, this function returns
all rows except the last `|n|` rows, equivalent to ``df[:n]``.

If n is larger than the number of rows, this function returns all rows.

**Examples:**

>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None

>>> df = bpd.DataFrame({'animal': ['alligator', 'bee', 'falcon', 'lion',
... 'monkey', 'parrot', 'shark', 'whale', 'zebra']})
>>> df
animal
0 alligator
1 bee
2 falcon
3 lion
4 monkey
5 parrot
6 shark
7 whale
8 zebra
<BLANKLINE>
[9 rows x 1 columns]

Viewing the first 5 lines:

>>> df.head()
animal
0 alligator
1 bee
2 falcon
3 lion
4 monkey
<BLANKLINE>
[5 rows x 1 columns]

Viewing the first `n` lines (three in this case):

>>> df.head(3)
animal
0 alligator
1 bee
2 falcon
<BLANKLINE>
[3 rows x 1 columns]

For negative values of `n`:

>>> df.head(-3)
animal
0 alligator
1 bee
2 falcon
3 lion
4 monkey
5 parrot
<BLANKLINE>
[6 rows x 1 columns]

Args:
n (int, default 5):
Default 5. Number of rows to select.

Returns:
The first `n` rows of the caller object.
same type as caller: The first ``n`` rows of the caller object.
"""
raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE)

Expand Down
15 changes: 14 additions & 1 deletion third_party/bigframes_vendored/pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,20 @@ def index(self):

@property
def shape(self):
"""Return a tuple of the shape of the underlying data."""
"""Return a tuple of the shape of the underlying data.

**Examples:**

>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None

>>> s = bpd.Series([1, 4, 9, 16])
>>> s.shape
(4,)
>>> s = bpd.Series(['Alice', 'Bob', bpd.NA])
>>> s.shape
(3,)
"""
raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE)

@property
Expand Down