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)

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 <[email protected]>
  • Loading branch information
mvashishtha authored Feb 25, 2023
1 parent 5e1660b commit 6f45431
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 9 deletions.
1 change: 0 additions & 1 deletion modin/core/execution/client/query_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,6 @@ def forwarding_method(self, by, *args, **kwargs):
"align",
"series_corr",
"divmod",
"reindex_like",
"rdivmod",
"corrwith" "merge_ordered",
}
Expand Down
8 changes: 0 additions & 8 deletions modin/pandas/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2110,14 +2110,6 @@ def _reindex(
final_query_compiler = new_query_compiler
return self._create_or_update_from_compiler(final_query_compiler, 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 @@ -2507,6 +2507,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 @@ -2113,6 +2113,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 6f45431

Please sign in to comment.