Skip to content

Commit

Permalink
reset index
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Feb 24, 2024
1 parent bf09c85 commit 8c56cf8
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions narwhals/pandas_like/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,14 +361,15 @@ def reverse_translate_dtype(dtype: DType | type[DType]) -> Any:
raise TypeError(msg)


def reset_index(df: Any) -> Any:
def reset_index(obj: Any) -> Any:
index = obj.index
if (
hasattr(df, "start")
and hasattr(df, "stop")
and hasattr(df, "step")
and df.start == 0
and df.stop == len(df)
and df.step == 1
hasattr(index, "start")
and hasattr(index, "stop")
and hasattr(index, "step")
and index.start == 0
and index.stop == len(obj)
and index.step == 1
):
return df
return df.reset_index(drop=True)
return obj
return obj.reset_index(drop=True)

0 comments on commit 8c56cf8

Please sign in to comment.