From fa66249bbcb04b3054c200dbe9ba0b1e29ec4a7b Mon Sep 17 00:00:00 2001 From: Ashley Xu Date: Sat, 6 Jan 2024 04:39:59 +0000 Subject: [PATCH 1/2] docs: add code samples for Series.ffill and DataFrame.ffill --- .../bigframes_vendored/pandas/core/generic.py | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/third_party/bigframes_vendored/pandas/core/generic.py b/third_party/bigframes_vendored/pandas/core/generic.py index 72b947f96c..cc35571bf6 100644 --- a/third_party/bigframes_vendored/pandas/core/generic.py +++ b/third_party/bigframes_vendored/pandas/core/generic.py @@ -627,6 +627,48 @@ def copy(self): def ffill(self, *, limit: Optional[int] = None): """Fill NA/NaN values by propagating the last valid observation to next valid. + **Examples:** + + >>> import bigframes.pandas as bpd + >>> import numpy as np + >>> bpd.options.display.progress_bar = None + + >>> df = bpd.DataFrame([[np.nan, 2, np.nan, 0], + ... [3, 4, np.nan, 1], + ... [np.nan, np.nan, np.nan, np.nan], + ... [np.nan, 3, np.nan, 4]], + ... columns=list("ABCD")).astype("Float64") + >>> df + A B C D + 0 2.0 0.0 + 1 3.0 4.0 1.0 + 2 + 3 3.0 4.0 + + [4 rows x 4 columns] + + Fill NA/NaN values in DataFrames: + + >>> df.ffill() + A B C D + 0 2.0 0.0 + 1 3.0 4.0 1.0 + 2 3.0 4.0 1.0 + 3 3.0 3.0 4.0 + + [4 rows x 4 columns] + + + Fill NA/NaN values in Series: + + >>> series = bpd.Series([1, np.nan, 2, 3]) + >>> series.ffill() + 0 1.0 + 1 1.0 + 2 2.0 + 3 3.0 + dtype: Float64 + Args: limit : int, default None If method is specified, this is the maximum number of consecutive From e24537e896b3182f1d11ac09880ec5f16d03bc5d Mon Sep 17 00:00:00 2001 From: Ashley Xu Date: Mon, 8 Jan 2024 04:39:21 +0000 Subject: [PATCH 2/2] address comments --- third_party/bigframes_vendored/pandas/core/generic.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/third_party/bigframes_vendored/pandas/core/generic.py b/third_party/bigframes_vendored/pandas/core/generic.py index cc35571bf6..2ca51f6493 100644 --- a/third_party/bigframes_vendored/pandas/core/generic.py +++ b/third_party/bigframes_vendored/pandas/core/generic.py @@ -639,7 +639,7 @@ def ffill(self, *, limit: Optional[int] = None): ... [np.nan, 3, np.nan, 4]], ... columns=list("ABCD")).astype("Float64") >>> df - A B C D + A B C D 0 2.0 0.0 1 3.0 4.0 1.0 2 @@ -650,7 +650,7 @@ def ffill(self, *, limit: Optional[int] = None): Fill NA/NaN values in DataFrames: >>> df.ffill() - A B C D + A B C D 0 2.0 0.0 1 3.0 4.0 1.0 2 3.0 4.0 1.0