Skip to content

Commit 1b98168

Browse files
committed
Add a fill_nan method to dataframe and column
Addresses half of gh-142 (`fill_null` is more complex, and not included here).
1 parent 15eda61 commit 1b98168

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

spec/API_specification/dataframe_api/column_object.py

+14
Original file line numberDiff line numberDiff line change
@@ -456,3 +456,17 @@ def unique_indices(self, *, skip_nulls: bool = True) -> Column[int]:
456456
To get the unique values, you can do ``col.get_rows(col.unique_indices())``.
457457
"""
458458
...
459+
460+
def fill_nan(self, value: float | null, /):
461+
"""
462+
Fill floating point ``nan`` values with the given fill value.
463+
464+
Parameters
465+
----------
466+
value : float or `null`
467+
Value used to replace any ``nan`` in the column with. Must be
468+
of the Python scalar type matching the dtype of the column (or
469+
be `null`).
470+
471+
"""
472+
...

spec/API_specification/dataframe_api/dataframe_object.py

+17
Original file line numberDiff line numberDiff line change
@@ -706,3 +706,20 @@ def isnan(self) -> DataFrame:
706706
In particular, does not check for `np.timedelta64('NaT')`.
707707
"""
708708
...
709+
710+
def fill_nan(self, value: float | null, /):
711+
"""
712+
Fill ``nan`` values with the given fill value.
713+
714+
The fill operation will apply to all columns with a floating-point
715+
dtype. Other columns remain unchanged.
716+
717+
Parameters
718+
----------
719+
value : float or `null`
720+
Value used to replace any ``nan`` in the column with. Must be
721+
of the Python scalar type matching the dtype of the column (or
722+
be `null`.
723+
724+
"""
725+
...

0 commit comments

Comments
 (0)