Skip to content

Commit 73dce26

Browse files
committed
add docstrings
1 parent e04393a commit 73dce26

File tree

3 files changed

+93
-65
lines changed

3 files changed

+93
-65
lines changed

bigframes/series.py

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2519,43 +2519,6 @@ def resample(
25192519
Literal["epoch", "start", "start_day", "end", "end_day"],
25202520
] = "start_day",
25212521
) -> bigframes.core.groupby.SeriesGroupBy:
2522-
"""Internal function to support resample. Resample time-series data.
2523-
2524-
**Examples:**
2525-
2526-
>>> import bigframes.pandas as bpd
2527-
>>> data = {
2528-
... "timestamp_col": pd.date_range(
2529-
... start="2021-01-01 13:00:00", periods=30, freq="1s"
2530-
... ),
2531-
... "int64_col": range(30),
2532-
... }
2533-
>>> s = bpd.DataFrame(data).set_index("timestamp_col")
2534-
>>> s.resample(rule="7s", origin="epoch").min()
2535-
int64_col
2536-
2021-01-01 12:59:56 0
2537-
2021-01-01 13:00:03 3
2538-
2021-01-01 13:00:10 10
2539-
2021-01-01 13:00:17 17
2540-
2021-01-01 13:00:24 24
2541-
<BLANKLINE>
2542-
[5 rows x 1 columns]
2543-
2544-
2545-
Args:
2546-
rule (str):
2547-
The offset string representing target conversion.
2548-
level (str or int, default None):
2549-
For a MultiIndex, level (name or number) to use for resampling.
2550-
level must be datetime-like.
2551-
origin(str, default 'start_day'):
2552-
The timestamp on which to adjust the grouping. Must be one of the following:
2553-
'epoch': origin is 1970-01-01
2554-
'start': origin is the first value of the timeseries
2555-
'start_day': origin is the first day at midnight of the timeseries
2556-
Returns:
2557-
SeriesGroupBy: SeriesGroupBy object.
2558-
"""
25592522
block = self._block._generate_resample_label(
25602523
rule=rule,
25612524
closed=closed,

third_party/bigframes_vendored/pandas/core/frame.py

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4752,40 +4752,40 @@ def resample(
47524752
47534753
**Examples:**
47544754
4755-
>>> import bigframes.pandas as bpd
4756-
>>> data = {
4757-
... "timestamp_col": pd.date_range(
4758-
... start="2021-01-01 13:00:00", periods=30, freq="1s"
4759-
... ),
4760-
... "int64_col": range(30),
4761-
... "int64_too": range(10, 40),
4762-
... }
4755+
>>> import bigframes.pandas as bpd
4756+
>>> data = {
4757+
... "timestamp_col": pd.date_range(
4758+
... start="2021-01-01 13:00:00", periods=30, freq="1s"
4759+
... ),
4760+
... "int64_col": range(30),
4761+
... "int64_too": range(10, 40),
4762+
... }
47634763
47644764
Resample on a DataFrame with index:
47654765
4766-
>>> df = bpd.DataFrame(data).set_index("timestamp_col")
4767-
>>> df.resample(rule="7s").min()
4768-
int64_col int64_too
4769-
2021-01-01 12:59:55 0 10
4770-
2021-01-01 13:00:02 2 12
4771-
2021-01-01 13:00:09 9 19
4772-
2021-01-01 13:00:16 16 26
4773-
2021-01-01 13:00:23 23 33
4774-
<BLANKLINE>
4775-
[5 rows x 2 columns]
4766+
>>> df = bpd.DataFrame(data).set_index("timestamp_col")
4767+
>>> df.resample(rule="7s").min()
4768+
int64_col int64_too
4769+
2021-01-01 12:59:55 0 10
4770+
2021-01-01 13:00:02 2 12
4771+
2021-01-01 13:00:09 9 19
4772+
2021-01-01 13:00:16 16 26
4773+
2021-01-01 13:00:23 23 33
4774+
<BLANKLINE>
4775+
[5 rows x 2 columns]
47764776
47774777
Resample with column and origin set to 'start':
47784778
4779-
>>> df = bpd.DataFrame(data)
4780-
>>> df.resample(rule="7s", on = "timestamp_col", origin="start").min()
4781-
int64_col int64_too
4782-
2021-01-01 13:00:00 0 10
4783-
2021-01-01 13:00:07 7 17
4784-
2021-01-01 13:00:14 14 24
4785-
2021-01-01 13:00:21 21 31
4786-
2021-01-01 13:00:28 28 38
4787-
<BLANKLINE>
4788-
[5 rows x 2 columns]
4779+
>>> df = bpd.DataFrame(data)
4780+
>>> df.resample(rule="7s", on = "timestamp_col", origin="start").min()
4781+
int64_col int64_too
4782+
2021-01-01 13:00:00 0 10
4783+
2021-01-01 13:00:07 7 17
4784+
2021-01-01 13:00:14 14 24
4785+
2021-01-01 13:00:21 21 31
4786+
2021-01-01 13:00:28 28 38
4787+
<BLANKLINE>
4788+
[5 rows x 2 columns]
47894789
47904790
Args:
47914791
rule (str):
@@ -4813,6 +4813,7 @@ def resample(
48134813
Returns:
48144814
DataFrameGroupBy: DataFrameGroupBy object.
48154815
"""
4816+
raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE)
48164817

48174818
def round(self, decimals):
48184819
"""

third_party/bigframes_vendored/pandas/core/series.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44
from __future__ import annotations
55

6+
import datetime
67
from typing import (
78
Hashable,
89
IO,
@@ -19,6 +20,7 @@
1920
from bigframes_vendored.pandas.core.generic import NDFrame
2021
import numpy
2122
import numpy as np
23+
import pandas as pd
2224
from pandas._typing import Axis, FilePath, NaPosition, WriteBuffer
2325
from pandas.api import extensions as pd_ext
2426

@@ -2502,6 +2504,68 @@ def replace(
25022504
"""
25032505
raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE)
25042506

2507+
def resample(
2508+
self,
2509+
rule: str,
2510+
*,
2511+
closed: Optional[Literal["right", "left"]] = None,
2512+
label: Optional[Literal["right", "left"]] = None,
2513+
level=None,
2514+
origin: Union[
2515+
Union[pd.Timestamp, datetime.datetime, numpy.datetime64, int, float, str],
2516+
Literal["epoch", "start", "start_day", "end", "end_day"],
2517+
] = "start_day",
2518+
):
2519+
"""Resample time-series data.
2520+
2521+
**Examples:**
2522+
2523+
>>> import bigframes.pandas as bpd
2524+
>>> data = {
2525+
... "timestamp_col": pd.date_range(
2526+
... start="2021-01-01 13:00:00", periods=30, freq="1s"
2527+
... ),
2528+
... "int64_col": range(30),
2529+
... }
2530+
>>> s = bpd.DataFrame(data).set_index("timestamp_col")
2531+
>>> s.resample(rule="7s", origin="epoch").min()
2532+
int64_col
2533+
2021-01-01 12:59:56 0
2534+
2021-01-01 13:00:03 3
2535+
2021-01-01 13:00:10 10
2536+
2021-01-01 13:00:17 17
2537+
2021-01-01 13:00:24 24
2538+
<BLANKLINE>
2539+
[5 rows x 1 columns]
2540+
2541+
Args:
2542+
rule (str):
2543+
The offset string representing target conversion.
2544+
Offsets 'ME', 'YE', 'QE', 'BME', 'BA', 'BQE', and 'W' are *not*
2545+
supported.
2546+
closed (Literal['left'] | None):
2547+
Which side of bin interval is closed. The default is 'left' for
2548+
all supported frequency offsets.
2549+
label (Literal['right'] | Literal['left'] | None):
2550+
Which bin edge label to label bucket with. The default is 'left'
2551+
for all supported frequency offsets.
2552+
on (str, default None):
2553+
For a DataFrame, column to use instead of index for resampling. Column
2554+
must be datetime-like.
2555+
level (str or int, default None):
2556+
For a MultiIndex, level (name or number) to use for resampling.
2557+
level must be datetime-like.
2558+
origin(str, default 'start_day'):
2559+
The timestamp on which to adjust the grouping. Must be one of the following:
2560+
'epoch': origin is 1970-01-01
2561+
'start': origin is the first value of the timeseries
2562+
'start_day': origin is the first day at midnight of the timeseries
2563+
Origin values 'end' and 'end_day' are *not* supported.
2564+
Returns:
2565+
SeriesGroupBy: SeriesGroupBy object.
2566+
"""
2567+
raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE)
2568+
25052569
def dropna(self, *, axis=0, inplace: bool = False, how=None) -> Series:
25062570
"""
25072571
Return a new Series with missing values removed.

0 commit comments

Comments
 (0)