Skip to content

BUG/DEPR: Fix unwanted warnings from the Series(Index[datetime objects]) deprecation #38182

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
jorisvandenbossche opened this issue Nov 30, 2020 · 8 comments · Fixed by #38679
Labels
Bug Deprecate Functionality to remove in pandas
Milestone

Comments

@jorisvandenbossche
Copy link
Member

jorisvandenbossche commented Nov 30, 2020

See #36697 (comment) and #37193 (comment)

Due to the Index.is_all_dates + Series(Index[datetime object]) deprecation warnings, there are several code examples that are not using this attribute or constructor method directly, that still cause this warning (from internal pandas code, without direct control over this by the user).

Users should not see unrelated deprecation warnings from the internals of pandas that they can't do anything about themselves, so IMO we should either fix those for 1.2, or delay the deprecationg for 1.3

@jorisvandenbossche jorisvandenbossche added Bug Deprecate Functionality to remove in pandas labels Nov 30, 2020
@jorisvandenbossche jorisvandenbossche added this to the 1.2 milestone Nov 30, 2020
@jorisvandenbossche jorisvandenbossche changed the title BUG/DEPR: Fix unwanted warnings from the Index.is_all_dates deprecation BUG/DEPR: Fix unwanted warnings from the Series(Index[datetime objects]) deprecation Nov 30, 2020
@jorisvandenbossche
Copy link
Member Author

cc @jbrockmendel

@jbrockmendel
Copy link
Member

there are several code examples that are not using this attribute or constructor method directly, that still cause this warning (from internal pandas code, without direct control over this by the user).

I see #37193 has been fixed. Are there others that we can just fix internally? I don't see any good option other than hunting these down.

Shorthand: dti = "instance of DatetimeIndex", dti_obj = dti.astype(object)

Two cases come to mind:

  1. User passes dti_obj as index to Series constructor, gets back a Series with dti. We correctly issue a warning.

  2. User does [anything else], internal code does something that ends up passing dti_obj to the Series constructor
    a) that Series (or its index) are never returned to the user (e.g. in BUG: record warnings related to DatetimeIndex #37193), and
    b) no relevant behavior depends on the deprecated behavior.

    We incorrectly issue a warning.

I can imagine (ugly) ways to check whether we're in case 1 vs case 2, but I don't have any idea how to determine at runtime that both 2a and 2b hold. Do you think that's feasible?

@jorisvandenbossche
Copy link
Member Author

jorisvandenbossche commented Dec 8, 2020

I see #37193 has been fixed.

I don't think it is fixed? (or at least not that I am aware of, and the linked PR only suppressed the warning in the tests, not in the actual code). See the linked example at #37193 (comment), which still raises the warning when plotting:

idx = pd.date_range("2012-6-22 21:59:51", freq="S", periods=100)
df = pd.DataFrame(np.random.randn(len(idx), 2), index=pd.Index(idx, dtype=object))

df.plot()

@jreback jreback modified the milestones: 1.2, 1.2.1 Dec 21, 2020
@jorisvandenbossche jorisvandenbossche modified the milestones: 1.2.1, 1.2 Dec 21, 2020
@simonjayhawkins
Copy link
Member

@jorisvandenbossche @jbrockmendel what's the status here? As this has not been fixed and the release is imminent are we reverting #36697 for 1.2 and deferring to 1.3?

@simonjayhawkins
Copy link
Member

@jorisvandenbossche @jbrockmendel @jreback can't be reverted automatically. will start the manual revert shortly. may not be difficult, but please lmk if this is not what we want to do.

@jorisvandenbossche
Copy link
Member Author

jorisvandenbossche commented Dec 24, 2020

It should certainly not be reverted fully. I think the is_all_dates deprecation is not causing any problems, but on the Series(..) construction

So only those lines in the diff: https://github.com/pandas-dev/pandas/pull/36697/files#diff-a5257444a1b322d619680fc77361cc6ea11ef36b363b4bb2289fdef0f41feb70R419-R425

@simonjayhawkins
Copy link
Member

Thanks @jorisvandenbossche i'll update #38679

@jbrockmendel
Copy link
Member

@jorisvandenbossche can you respond to #38182 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Deprecate Functionality to remove in pandas
Projects
None yet
4 participants