Skip to content

Commit

Permalink
FEAT: Add partial support for df.pct_change() [UPSTREAM] (modin-pro…
Browse files Browse the repository at this point in the history
…ject#21)

* FEAT: Add partial support for df.pct_change()
  • Loading branch information
Karthik Velayutham authored Mar 23, 2023
1 parent 9492968 commit f319c29
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions modin/pandas/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2082,8 +2082,19 @@ def pct_change(
"""
Percentage change between the current and a prior element.
"""
return self._query_compiler.pct_change(
periods, fill_method, limit, freq, **kwargs
# Attempting to match pandas error behavior here
if not isinstance(periods, int):
raise ValueError(f"periods must be an int. got {type(periods)} instead")

# Attempting to match pandas error behavior here
for dtype in self._get_dtypes():
if not is_numeric_dtype(dtype):
raise TypeError(f"unsupported operand type for /: got {dtype}")

return self.__constructor__(
query_compiler=self._query_compiler.pct_change(
periods, fill_method, limit, freq, **kwargs
)
)

def pipe(self, func, *args, **kwargs): # noqa: PR01, RT01, D200
Expand Down

0 comments on commit f319c29

Please sign in to comment.