Skip to content

Series.values deprecation of converts and drops #58856

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

Closed

Conversation

pedrocariellof
Copy link
Contributor

Added the warnings in the function external_values in "pandas/core/internals/blocks.py" and added most of the asserts in the tests. Some tests will not pass, because they sometimes would show the warning and sometimes wouldn't so I didn't know what to do.

@pedrocariellof
Copy link
Contributor Author

I was thinking about changing the stack_level on the warning so we don't need to do as much asserts on the tests.

Copy link
Member

@rhshadrach rhshadrach left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! In many of the tests, users would be getting a warning about .values even when they are not using .values. We need to:

  • Determine when the behavior will change on the user, and only raise warnings when it will.
  • For cases that will change, raise an appropriate error message. It should make sense to the user why they are getting the warning, and how they can work around it to either preserve the old behavior or adopt future behavior (and silence the warning).

@@ -200,6 +200,7 @@ starting with 3.0, so it can be safely removed from your code.
Other Deprecations
^^^^^^^^^^^^^^^^^^

- Deprecated :meth:`series.values`, now don't drops the ``tz`` from ``dt64tz``, converts ``interval`` to ``object``, converts ``period`` to ``object``.
Copy link
Member

Choose a reason for hiding this comment

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

Should be Series (not series) throughout this PR.

Comment on lines +2352 to +2356
warnings.warn(
"series.values will stop converting tz from dt64tz, interval to object and period to object",
FutureWarning,
stacklevel=find_stack_level(),
)
Copy link
Member

Choose a reason for hiding this comment

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

Can you make this warning specific to period / interval. In other words, if they have period data, they should just see the message for period.

Comment on lines +2362 to +2366
warnings.warn(
"series.values will stop converting tz from dt64tz, interval to object and period to object",
FutureWarning,
stacklevel=find_stack_level(),
)
Copy link
Member

Choose a reason for hiding this comment

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

If the data is tz-agnostic, then there will be no behavior change. So users should not see a warning.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How can I see if the data is tz-agnostic?

Copy link
Member

Choose a reason for hiding this comment

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

I believe isinstance(values.dtype, pd.DatetimeTZDtype)

Comment on lines +1514 to +1519
res = self.eval(
"df.dates1 < 20130101",
local_dict={"df": df},
engine=engine,
parser=parser,
)
Copy link
Member

@rhshadrach rhshadrach Jun 10, 2024

Choose a reason for hiding this comment

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

The "user" is not using .values here, they should not see a warning (at least in regards to using .values). Will the behavior here actually change for a user?

@rhshadrach rhshadrach added Deprecate Functionality to remove in pandas IO Data IO issues that don't fit into a more specific label and removed IO Data IO issues that don't fit into a more specific label labels Jun 10, 2024
@mroeschke
Copy link
Member

Thanks for the pull request, but it appears to have gone stale. If interested in continuing, please merge in the main branch, address any review comments and/or failing tests, and we can reopen.

@mroeschke mroeschke closed this Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecate Functionality to remove in pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DEPR: values casting dt64tz, Interval, Period
3 participants