|
3 | 3 | """ |
4 | 4 | from __future__ import annotations |
5 | 5 |
|
| 6 | +import datetime |
6 | 7 | from typing import ( |
7 | 8 | Hashable, |
8 | 9 | IO, |
|
19 | 20 | from bigframes_vendored.pandas.core.generic import NDFrame |
20 | 21 | import numpy |
21 | 22 | import numpy as np |
| 23 | +import pandas as pd |
22 | 24 | from pandas._typing import Axis, FilePath, NaPosition, WriteBuffer |
23 | 25 | from pandas.api import extensions as pd_ext |
24 | 26 |
|
@@ -2502,6 +2504,68 @@ def replace( |
2502 | 2504 | """ |
2503 | 2505 | raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) |
2504 | 2506 |
|
| 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 | + |
2505 | 2569 | def dropna(self, *, axis=0, inplace: bool = False, how=None) -> Series: |
2506 | 2570 | """ |
2507 | 2571 | Return a new Series with missing values removed. |
|
0 commit comments