Skip to content

repr of MultiIndexed frame with NaT as the first element of level 0 of the index raises during repr #7406

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
cpcloud opened this issue Jun 9, 2014 · 0 comments · Fixed by #7410
Assignees
Labels
Bug MultiIndex Output-Formatting __repr__ of pandas objects, to_string
Milestone

Comments

@cpcloud
Copy link
Member

cpcloud commented Jun 9, 2014

world's longest PR title, for a very strange bug

In [145]: idx = pd.to_datetime([pd.NaT] + pd.date_range('20130101', periods=2).tolist())

In [146]: idx
Out[146]:
<class 'pandas.tseries.index.DatetimeIndex'>
[NaT, ..., 2013-01-02]
Length: 3, Freq: None, Timezone: None

In [149]: df = DataFrame({'X': range(len(idx))}, index=[idx, tm.choice(list('ab'), size=len(idx))])

In [150]: df
Out[150]: <repr(<pandas.core.frame.DataFrame at 0x7ff147824950>) failed: ValueError: boolean index array has too many values>

but strangely enough if I construct it with slightly different dates it works fine:

In [184]: idx = pd.to_datetime([pd.NaT, pd.Timestamp('2013-01-01'), pd.Timestamp('2013-01-02')])

In [185]: df = DataFrame({'X': range(len(idx))}, index=[idx, tm.choice(list('ab'), size=len(idx))])

In [186]: df
Out[186]: <repr(<pandas.core.frame.DataFrame at 0x7ff14792d1d0>) failed: ValueError: boolean index array has too many values>

In [187]: idx = pd.to_datetime([pd.NaT, pd.Timestamp('2013-01-03'), pd.Timestamp('2013-01-02')])

In [188]: df = DataFrame({'X': range(len(idx))}, index=[idx, tm.choice(list('ab'), size=len(idx))])

In [189]: df
Out[189]:
              X
NaN        a  0
2013-01-03 b  1
2013-01-02 a  2
@cpcloud cpcloud changed the title repr of MultiIndexed frame with NaT as the first element of level 0 of the index throws an error message during repr repr of MultiIndexed frame with NaT as the first element of level 0 of the index raises during repr Jun 9, 2014
@cpcloud cpcloud self-assigned this Jun 9, 2014
@cpcloud cpcloud added this to the 0.14.1 milestone Jun 9, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug MultiIndex Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant