Skip to content

Add a fill_nan method to dataframe and column #167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions spec/API_specification/dataframe_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@
from ._types import DType


__all__ = [
"__dataframe_api_version",
"column_from_sequence",
"concat",
"dataframe_from_dict",
"isnull",
"null",
]


__dataframe_api_version__: str = "YYYY.MM"
"""
String representing the version of the DataFrame API specification to which
Expand Down
14 changes: 14 additions & 0 deletions spec/API_specification/dataframe_api/column_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,3 +456,17 @@ def unique_indices(self, *, skip_nulls: bool = True) -> Column[int]:
To get the unique values, you can do ``col.get_rows(col.unique_indices())``.
"""
...

def fill_nan(self, value: float | 'null', /) -> Column:
"""
Fill floating point ``nan`` values with the given fill value.

Parameters
----------
value : float or `null`
Value used to replace any ``nan`` in the column with. Must be
of the Python scalar type matching the dtype of the column (or
be `null`).

"""
...
17 changes: 17 additions & 0 deletions spec/API_specification/dataframe_api/dataframe_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,3 +706,20 @@ def isnan(self) -> DataFrame:
In particular, does not check for `np.timedelta64('NaT')`.
"""
...

def fill_nan(self, value: float | 'null', /) -> DataFrame:
"""
Fill ``nan`` values with the given fill value.

The fill operation will apply to all columns with a floating-point
dtype. Other columns remain unchanged.

Parameters
----------
value : float or `null`
Value used to replace any ``nan`` in the column with. Must be
of the Python scalar type matching the dtype of the column (or
be `null`).

"""
...