Skip to content
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
5 changes: 5 additions & 0 deletions bigframes/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,11 @@ def __pos__(self) -> DataFrame:
def __neg__(self) -> DataFrame:
return self._apply_unary_op(ops.neg_op)

def __abs__(self) -> DataFrame:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to add the docstring for this method too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

return self._apply_unary_op(ops.abs_op)

__abs__.__doc__ = abs.__doc__

def align(
self,
other: typing.Union[DataFrame, bigframes.series.Series],
Expand Down
2 changes: 2 additions & 0 deletions bigframes/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1363,6 +1363,8 @@ def update(self, other: Union[Series, Sequence, Mapping]) -> None:
def __abs__(self) -> Series:
return self.abs()

__abs__.__doc__ = inspect.getdoc(vendored_pandas_series.Series.abs)

def abs(self) -> Series:
return self._apply_unary_op(ops.abs_op)

Expand Down
10 changes: 10 additions & 0 deletions tests/system/small/test_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -2460,6 +2460,16 @@ def test_df_neg(scalars_dfs):
assert_pandas_df_equal(pd_result, bf_result)


def test_df__abs__(scalars_dfs):
scalars_df, scalars_pandas_df = scalars_dfs
bf_result = (
abs(scalars_df[["int64_col", "numeric_col", "float64_col"]])
).to_pandas()
pd_result = abs(scalars_pandas_df[["int64_col", "numeric_col", "float64_col"]])

assert_pandas_df_equal(pd_result, bf_result)


def test_df_invert(scalars_dfs):
scalars_df, scalars_pandas_df = scalars_dfs
columns = ["int64_col", "bool_col"]
Expand Down