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

BUG: partial string indexing with PeriodIndex #6716

Closed
jreback opened this issue Mar 27, 2014 · 0 comments · Fixed by #7043
Closed

BUG: partial string indexing with PeriodIndex #6716

jreback opened this issue Mar 27, 2014 · 0 comments · Fixed by #7043
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves Period Period data type
Milestone

Comments

@jreback
Copy link
Contributor

jreback commented Mar 27, 2014

partial indexing works with time series, but not period index

In [27]: df2 = DataFrame(np.arange(20).reshape(10,2),index=pd.date_range('20130101 09:00',freq='T',periods=10))

In [28]: df = DataFrame(np.arange(20).reshape(10,2),index=pd.period_range('20130101 09:00',freq='T',periods=10))

In [29]: df2['20130101']
Out[29]: 
                      0   1
2013-01-01 09:00:00   0   1
2013-01-01 09:01:00   2   3
2013-01-01 09:02:00   4   5
2013-01-01 09:03:00   6   7
2013-01-01 09:04:00   8   9
2013-01-01 09:05:00  10  11
2013-01-01 09:06:00  12  13
2013-01-01 09:07:00  14  15
2013-01-01 09:08:00  16  17
2013-01-01 09:09:00  18  19

[10 rows x 2 columns]

In [30]: df['20130101']
KeyError: u'no item named 20130101'

In [31]: df2['20130101 09']
Out[31]: 
                      0   1
2013-01-01 09:00:00   0   1
2013-01-01 09:01:00   2   3
2013-01-01 09:02:00   4   5
2013-01-01 09:03:00   6   7
2013-01-01 09:04:00   8   9
2013-01-01 09:05:00  10  11
2013-01-01 09:06:00  12  13
2013-01-01 09:07:00  14  15
2013-01-01 09:08:00  16  17
2013-01-01 09:09:00  18  19

[10 rows x 2 columns]

In [32]: df['20130101 09']
KeyError: u'no item named 20130101 09'

Works fine for exact start points

In [34]: df2['20130101 09:05':]
Out[34]: 
                      0   1
2013-01-01 09:05:00  10  11
2013-01-01 09:06:00  12  13
2013-01-01 09:07:00  14  15
2013-01-01 09:08:00  16  17
2013-01-01 09:09:00  18  19

[5 rows x 2 columns]

In [35]: df['20130101 09:05':]
Out[35]: 
                   0   1
2013-01-01 09:05  10  11
2013-01-01 09:06  12  13
2013-01-01 09:07  14  15
2013-01-01 09:08  16  17
2013-01-01 09:09  18  19

[5 rows x 2 columns]
@jreback jreback added this to the 0.15.0 milestone Mar 27, 2014
@jreback jreback modified the milestones: 0.14.1, 0.15.0 May 5, 2014
@jreback jreback modified the milestones: 0.14.0, 0.14.1 May 13, 2014
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 Period Period data type
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant