Skip to content

Commit 1c63b45

Browse files
authored
docs: add code samples for Series.ffill and DataFrame.ffill (#307)
* docs: add code samples for Series.ffill and DataFrame.ffill * address comments
1 parent 21391a9 commit 1c63b45

File tree

1 file changed

+42
-0
lines changed
  • third_party/bigframes_vendored/pandas/core

1 file changed

+42
-0
lines changed

third_party/bigframes_vendored/pandas/core/generic.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,48 @@ def copy(self):
627627
def ffill(self, *, limit: Optional[int] = None):
628628
"""Fill NA/NaN values by propagating the last valid observation to next valid.
629629
630+
**Examples:**
631+
632+
>>> import bigframes.pandas as bpd
633+
>>> import numpy as np
634+
>>> bpd.options.display.progress_bar = None
635+
636+
>>> df = bpd.DataFrame([[np.nan, 2, np.nan, 0],
637+
... [3, 4, np.nan, 1],
638+
... [np.nan, np.nan, np.nan, np.nan],
639+
... [np.nan, 3, np.nan, 4]],
640+
... columns=list("ABCD")).astype("Float64")
641+
>>> df
642+
A B C D
643+
0 <NA> 2.0 <NA> 0.0
644+
1 3.0 4.0 <NA> 1.0
645+
2 <NA> <NA> <NA> <NA>
646+
3 <NA> 3.0 <NA> 4.0
647+
<BLANKLINE>
648+
[4 rows x 4 columns]
649+
650+
Fill NA/NaN values in DataFrames:
651+
652+
>>> df.ffill()
653+
A B C D
654+
0 <NA> 2.0 <NA> 0.0
655+
1 3.0 4.0 <NA> 1.0
656+
2 3.0 4.0 <NA> 1.0
657+
3 3.0 3.0 <NA> 4.0
658+
<BLANKLINE>
659+
[4 rows x 4 columns]
660+
661+
662+
Fill NA/NaN values in Series:
663+
664+
>>> series = bpd.Series([1, np.nan, 2, 3])
665+
>>> series.ffill()
666+
0 1.0
667+
1 1.0
668+
2 2.0
669+
3 3.0
670+
dtype: Float64
671+
630672
Args:
631673
limit : int, default None
632674
If method is specified, this is the maximum number of consecutive

0 commit comments

Comments
 (0)