Skip to content

BUG/API: Index.__new__ match Series datetime inference behavior #40451

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

jbrockmendel
Copy link
Member

  • closes #xxxx
  • tests added / passed
  • Ensure all linting tests pass, see here for how to run them
  • whatsnew entry

This makes us slightly more aggressive in casting to dt64 in Index.__new__ (see the added test_index_new test, it contains all of the cases that are reached in the existing tests where the current behavior differs from the PR behavior)

Technically an API change, but I think its worth it to match the Series behavior.

Found+fixed a pd.array bug along the way.

@jbrockmendel
Copy link
Member Author

@MarcoGorelli any idea whats going on with the docstring validation script test?

# mixed str/datetime
data = ["2012-12-31", datetime(2013, 1, 1), datetime(2013, 1, 2)]
result = Index(data)
expected = DatetimeIndex([Timestamp(x) for x in data])
Copy link
Member

Choose a reason for hiding this comment

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

I don't find this an improvement (IMO we shouldn't infer strings just because timestamps are present), so if we want to (eventually) achieve consistency, I would rather deprecate this in the Series constructor.

@jbrockmendel jbrockmendel added API - Consistency Internal Consistency of API/Behavior Index Related to the Index class or subclasses labels Mar 22, 2021
@jbrockmendel
Copy link
Member Author

mothballing to clear the queue

@jbrockmendel jbrockmendel added the Mothballed Temporarily-closed PR the author plans to return to label Mar 23, 2021
@jbrockmendel jbrockmendel deleted the ref-index-constructors-5 branch November 8, 2021 16:35
@jbrockmendel jbrockmendel removed the Mothballed Temporarily-closed PR the author plans to return to label Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API - Consistency Internal Consistency of API/Behavior Index Related to the Index class or subclasses
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants