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

NaT in MultiIndex throws ValueError when reset_index() is called. #10388

Closed
jstritar opened this issue Jun 18, 2015 · 2 comments · Fixed by #10389
Closed

NaT in MultiIndex throws ValueError when reset_index() is called. #10388

jstritar opened this issue Jun 18, 2015 · 2 comments · Fixed by #10389
Labels
Bug Datetime Datetime data dtype Indexing Related to indexing on series/frames, not to indexes themselves Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate MultiIndex
Milestone

Comments

@jstritar
Copy link

Please see this test case:

x = pp.DataFrame({
    'other': ['a', np.nan],
    'date': ['2015-03-22', np.nan],
    'amount': [2, 3]
  })
x.date = pp.to_datetime(x.date)
index amount date other
0 2 2015-03-22 a
1 3 NaT NaN

The reset_index here then fails with the error below:

x.set_index(['other', 'date']).reset_index()

ValueError: Converting an integer to a NumPy datetime requires a specified unit

pp.version.version
'0.16.1'
pp.np.version.version
'1.7.1'

@jreback jreback added Bug Datetime Datetime data dtype Indexing Related to indexing on series/frames, not to indexes themselves Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate MultiIndex Difficulty Intermediate labels Jun 18, 2015
@jreback jreback added this to the Next Major Release milestone Jun 18, 2015
@jreback
Copy link
Contributor

jreback commented Jun 18, 2015

hmm, thought we had an issue for this, guess not. This core.common._maybe_upcast_putmask is kind of wonky (was needed when Series was a ndarray sub-class), but I think can be replaced but a block operation (I think).

@jstritar
Copy link
Author

Do you recommend any work around?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Datetime Datetime data dtype Indexing Related to indexing on series/frames, not to indexes themselves Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate MultiIndex
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants