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: add examples for dataframe.nunique, dataframe.diff, dataframe.a… #251

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 6 commits into from
Dec 5, 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
114 changes: 112 additions & 2 deletions 114 third_party/bigframes_vendored/pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3434,7 +3434,26 @@ def melt(self, id_vars, value_vars, var_name, value_name):

def nunique(self):
"""
Count number of distinct elements in specified axis.
Count number of distinct elements in each column.

**Examples:**

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

>>> df = bpd.DataFrame({"A": [3, 1, 2], "B": [1, 2, 2]})
>>> df
A B
0 3 1
1 1 2
2 2 2
<BLANKLINE>
[3 rows x 2 columns]

>>> df.nunique()
A 3.0
B 2.0
dtype: Float64

Returns:
bigframes.series.Series: Series with number of distinct elements.
Expand Down Expand Up @@ -3578,6 +3597,40 @@ def diff(
Calculates the difference of a DataFrame element compared with another
element in the DataFrame (default is element in previous row).

**Examples:**

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

>>> df = bpd.DataFrame({"A": [3, 1, 2], "B": [1, 2, 3]})
>>> df
A B
0 3 1
1 1 2
2 2 3
<BLANKLINE>
[3 rows x 2 columns]

Calculating difference with default periods=1:

>>> df.diff()
A B
0 <NA> <NA>
1 -2 1
2 1 1
<BLANKLINE>
[3 rows x 2 columns]

Calculating difference with periods=-1:

>>> df.diff(periods=-1)
A B
0 2 -1
1 -1 -1
2 <NA> <NA>
<BLANKLINE>
[3 rows x 2 columns]

Args:
periods (int, default 1):
Periods to shift for calculating difference, accepts negative
Expand All @@ -3590,7 +3643,37 @@ def diff(

def agg(self, func):
"""
Aggregate using one or more operations over the specified axis.
Aggregate using one or more operations over columns.

**Examples:**

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

>>> df = bpd.DataFrame({"A": [3, 1, 2], "B": [1, 2, 3]})
>>> df
A B
0 3 1
1 1 2
2 2 3
<BLANKLINE>
[3 rows x 2 columns]

Using a single function:

>>> df.agg('sum')
A 6.0
B 6.0
dtype: Float64

Using a list of functions:

>>> df.agg(['sum', 'mean'])
A B
sum 6.0 6.0
mean 2.0 2.0
<BLANKLINE>
[2 rows x 2 columns]

Args:
func (function):
Expand Down Expand Up @@ -3623,6 +3706,33 @@ def describe(self):
upper percentile is ``75``. The ``50`` percentile is the
same as the median.

**Examples:**

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

>>> df = bpd.DataFrame({"A": [3, 1, 2], "B": [0, 2, 8]})
>>> df
A B
0 3 0
1 1 2
2 2 8
<BLANKLINE>
[3 rows x 2 columns]

>>> df.describe()
A B
count 3.0 3.0
mean 2.0 3.333333
std 1.0 4.163332
min 1.0 0.0
25% 1.0 0.0
50% 2.0 2.0
75% 3.0 8.0
max 3.0 8.0
<BLANKLINE>
[8 rows x 2 columns]

Returns:
bigframes.dataframe.DataFrame: Summary statistics of the Series or Dataframe provided.
"""
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.