Skip to content
Draft
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 bigframes/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,16 @@ def value_counts(

return series.Series(block)

def isna(self) -> Index:
return self._apply_unary_op(ops.isnull_op)

isnull = isna

def notna(self) -> Index:
return self._apply_unary_op(ops.notnull_op)

notnull = notna

def fillna(self, value=None) -> Index:
if self.nlevels > 1:
raise TypeError("Multiindex does not support 'fillna'")
Expand Down
14 changes: 14 additions & 0 deletions tests/system/small/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,20 @@ def test_index_fillna(scalars_df_index, scalars_pandas_df_index):
pd.testing.assert_index_equal(bf_result, pd_result)


def test_index_isna(scalars_df_index, scalars_pandas_df_index):
bf_result = scalars_df_index.set_index("int64_col").index.isna().to_pandas()
pd_result = scalars_pandas_df_index.set_index("int64_col").index.isna()

pd.testing.assert_index_equal(bf_result, pd.Index(pd_result))


def test_index_notna(scalars_df_index, scalars_pandas_df_index):
bf_result = scalars_df_index.set_index("float64_col").index.notna().to_pandas()
pd_result = scalars_pandas_df_index.set_index("float64_col").index.notna()

pd.testing.assert_index_equal(bf_result, pd.Index(pd_result))


def test_index_drop(scalars_df_index, scalars_pandas_df_index):
bf_result = (
scalars_df_index.set_index("int64_col").index.drop([2, 314159]).to_pandas()
Expand Down
32 changes: 32 additions & 0 deletions third_party/bigframes_vendored/pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,38 @@ def fillna(self, value) -> Index:
"""
raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE)

def isna(self):
"""
Detect missing values.

Return a boolean same-sized object indicating if the values are NA.
NA values, such as ``None``, :attr:`numpy.NaN` or :attr:`pd.NaT`, get
mapped to ``True`` values.
Everything else get mapped to ``False`` values. Characters such as
empty strings `''` or :attr:`numpy.inf` are not considered NA values.

Returns:
Index:
Boolean index to indicate which entries are NA.
"""
raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE)

def notna(self):
"""
Detect existing (non-missing) values.

Return a boolean same-sized object indicating if the values are not NA.
Non-missing values get mapped to ``True``. Characters such as empty
strings ``''`` or :attr:`numpy.inf` are not considered NA values.
NA values, such as None or :attr:`numpy.NaN`, get mapped to ``False``
values.

Returns:
Index:
Boolean index to indicate which entries are not NA.
"""
raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE)

def rename(self, name, *, inplace):
"""
Alter Index or MultiIndex name.
Expand Down