Skip to content

Commit 2950673

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

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

spec/API_specification/dataframe_api/__init__.py

+10
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@
1212
from ._types import DType
1313

1414

15+
__all__ = [
16+
"__dataframe_api_version",
17+
"column_from_sequence",
18+
"concat",
19+
"dataframe_from_dict",
20+
"isnull",
21+
"null",
22+
]
23+
24+
1525
__dataframe_api_version__: str = "YYYY.MM"
1626
"""
1727
String representing the version of the DataFrame API specification to which

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', /) -> Column:
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', /) -> DataFrame:
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)