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

Incorrect behaviour when using periods in a hierarchical index #1705

Closed
kdebrab opened this issue Jul 30, 2012 · 0 comments
Closed

Incorrect behaviour when using periods in a hierarchical index #1705

kdebrab opened this issue Jul 30, 2012 · 0 comments
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves Timeseries
Milestone

Comments

@kdebrab
Copy link
Contributor

kdebrab commented Jul 30, 2012

Pandas 0.8.1:

import pandas as pd
index = pd.date_range('1/1/2012',periods=4,freq='12H')
index_as_arrays = [index.to_period(freq='D'), index.hour]
pd.Series([0, 1, 2, 3], index_as_arrays)

incorrectly returns:

15340  0     0
       12    1
15341  0     2
       12    3

The correct result is obtained though when explicitly building the MultiIndex:

index_as_multi_index = pd.MultiIndex.from_tuples(zip(*index_as_arrays))
pd.Series([0, 1, 2, 3], index_as_multi_index)

correctly returns:

01-Jan-2012  0     0
             12    1
02-Jan-2012  0     2
             12    3
@wesm wesm closed this as completed in 4e36441 Aug 12, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves Timeseries
Projects
None yet
Development

No branches or pull requests

2 participants