Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-1642295: Support lazy index objects in DataFrame.reindex and Series.reindex #2176

Conversation

sfc-gh-vbudati
Copy link
Contributor

  1. Which Jira issue is this PR addressing? Make sure that there is an accompanying issue to your PR.

    Fixes SNOW-1642295

  2. Fill out the following pre-review checklist:

    • I am adding a new automated test(s) to verify correctness of my new code
      • If this test skips Local Testing mode, I'm requesting review from @snowflakedb/local-testing
    • I am adding new logging messages
    • I am adding a new telemetry message
    • I am adding new credentials
    • I am adding a new dependency
    • If this is a new feature/behavior, I'm adding the Local Testing parity changes.
  3. Please describe how your code solves the related issue.

    Added support for lazy index objects in DataFrame.reindex and Series.reindex.

>>> ser = pd.Series([1, 2, 3], index=["A", "B", "C"])
>>> idx = pd.Index(["X", "Y", "Z"])
>>> ser.reindex(idx)
X   NaN
Y   NaN
Z   NaN
dtype: float64

@sfc-gh-vbudati sfc-gh-vbudati added the NO-PANDAS-CHANGEDOC-UPDATES This PR does not update Snowpark pandas docs label Aug 28, 2024
@sfc-gh-vbudati sfc-gh-vbudati requested a review from a team as a code owner August 28, 2024 01:08
@@ -2369,7 +2369,10 @@ def _reindex_axis_0(
"""
self._raise_not_implemented_error_for_timedelta()

new_index_qc = pd.Series(labels)._query_compiler
if isinstance(labels, pd.Index):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if isinstance(labels, pd.Index):
if isinstance(labels, (pd.Index, pandas.Index)):

I believe if we do this, we can fix the name bug 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.

I don't think that would work directly since native pandas Series don't have a query compiler attribute

Copy link
Collaborator

Choose a reason for hiding this comment

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

Then you convert it to pd.Index first.

@sfc-gh-vbudati
Copy link
Contributor Author

I'm going to combine this PR with the index name bug PR: #2175

@github-actions github-actions bot locked and limited conversation to collaborators Aug 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
NO-PANDAS-CHANGEDOC-UPDATES This PR does not update Snowpark pandas docs snowpark-pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants