Skip to content

Commit

Permalink
FIX: Fix API layer implementation of reindex_like [upstream] (modin-p…
Browse files Browse the repository at this point in the history
…roject#75) [core]

Note for upstream and rebase: Don't worry about the client query compiler change
here as it's just deleting an unused method. Don't need to upstream or add into
the next modin branch on the next rebase.

Signed-off-by: mvashishtha <mahesh@ponder.io>
  • Loading branch information
mvashishtha authored and vnlitvinov committed Mar 16, 2023
1 parent 2f48077 commit 60d682a
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 8 deletions.
8 changes: 0 additions & 8 deletions modin/pandas/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2232,14 +2232,6 @@ def reindex(
final_query_compiler, inplace=False if copy is None else not copy
)

def reindex_like(
self, other, method=None, copy=True, limit=None, tolerance=None
): # noqa: PR01, RT01, D200
"""
Return an object with matching indices as `other` object.
"""
return self._query_compiler.reindex_like(other, method, copy, limit, tolerance)

def rename_axis(
self, mapper=None, index=None, columns=None, axis=None, copy=True, inplace=False
): # noqa: PR01, RT01, D200
Expand Down
24 changes: 24 additions & 0 deletions modin/pandas/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -2877,6 +2877,30 @@ def style(df):

return self._default_to_pandas(style)

def reindex_like(
self: "DataFrame",
other,
method=None,
copy: bool = True,
limit=None,
tolerance=None,
) -> "DataFrame":
# docs say "Same as calling .reindex(index=other.index, columns=other.columns,...).":
# https://pandas.pydata.org/pandas-docs/version/1.4/reference/api/pandas.DataFrame.reindex_like.html
return self.reindex(
index=other.index,
method=method,
copy=copy,
limit=limit,
tolerance=tolerance,
).reindex(
columns=other.columns,
method=method,
copy=copy,
limit=limit,
tolerance=tolerance,
)

def _create_or_update_from_compiler(self, new_query_compiler, inplace=False):
"""
Return or update a ``DataFrame`` with given `new_query_compiler`.
Expand Down
18 changes: 18 additions & 0 deletions modin/pandas/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2202,6 +2202,24 @@ def str(self): # noqa: RT01, D200

return StringMethods(self)

def reindex_like(
self: "Series",
other,
method=None,
copy: bool = True,
limit=None,
tolerance=None,
) -> "Series":
# docs say "Same as calling .reindex(index=other.index, columns=other.columns,...).":
# https://pandas.pydata.org/pandas-docs/version/1.4/reference/api/pandas.Series.reindex_like.html
return self.reindex(
index=other.index,
method=method,
copy=copy,
limit=limit,
tolerance=tolerance,
)

def _to_pandas(self):
"""
Convert Modin Series to pandas Series.
Expand Down

0 comments on commit 60d682a

Please sign in to comment.