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: selection from unordered time-series has incorrect / odd behavior #3448

Closed
jreback opened this issue Apr 24, 2013 · 1 comment · Fixed by #3452
Closed

BUG: selection from unordered time-series has incorrect / odd behavior #3448

jreback opened this issue Apr 24, 2013 · 1 comment · Fixed by #3452
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Indexing Related to indexing on series/frames, not to indexes themselves
Milestone

Comments

@jreback
Copy link
Contributor

jreback commented Apr 24, 2013

original mods made < 0.11 in #3136 / #2437

incorrect selections, depending on the start:end pos gettting weird values

also should be able to select a value that's bigger/smaller than the contained range and have it work (this is how ordered series works)

[21]: s = Series(randn(10),date_range('20130101',periods=10))

In [22]: x = s.index.values

In [23]: random.shuffle(x)

In [24]: s.index = x

In [25]: s
Out[25]: 
2013-01-09    0.911882
2013-01-06   -0.310166
2013-01-10    1.090196
2013-01-07   -0.846249
2013-01-02   -0.205013
2013-01-08   -1.284152
2013-01-05    0.018700
2013-01-04   -0.503527
2013-01-01    0.073035
2013-01-03    0.695904
dtype: float64

In [26]: s['20130104':'20130105']
Out[26]: Series([], dtype: float64)

In [27]: s['20130104':'20130107']
Out[27]: Series([], dtype: float64)

In [28]: s['20130102':'20130107']
Out[28]: Series([], dtype: float64)

In [29]: s['20130102':'20130104']
Out[29]: 
2013-01-02   -0.205013
2013-01-08   -1.284152
2013-01-05    0.018700
2013-01-04   -0.503527
dtype: float64
@jreback
Copy link
Contributor Author

jreback commented Apr 25, 2013

closed by #3452

Revised using code from above

In [14]: s
Out[14]: 
2013-01-01   -0.950737
2013-01-06    0.766329
2013-01-02    0.234236
2013-01-07   -1.009092
2013-01-03    0.519744
2013-01-09    0.736012
2013-01-04    1.063657
2013-01-05   -0.383949
2013-01-08   -2.117098
2013-01-10   -0.761778
dtype: float64

In [15]: s['20130104':'20130105']
Out[15]: 
2013-01-04    1.063657
2013-01-05   -0.383949
dtype: float64

Ordering is whatever it is currently (no sorting done on return index)

In [16]: s['20130104':'20130107']
Out[16]: 
2013-01-06    0.766329
2013-01-07   -1.009092
2013-01-04    1.063657
2013-01-05   -0.383949
dtype: float64

In [17]: s['20130102':'20130107']
Out[17]: 
2013-01-06    0.766329
2013-01-02    0.234236
2013-01-07   -1.009092
2013-01-03    0.519744
2013-01-04    1.063657
2013-01-05   -0.383949
dtype: float64

This is out of range selection!

In [18]: s['20130102':'20130204']
Out[18]: 
2013-01-06    0.766329
2013-01-02    0.234236
2013-01-07   -1.009092
2013-01-03    0.519744
2013-01-09    0.736012
2013-01-04    1.063657
2013-01-05   -0.383949
2013-01-08   -2.117098
2013-01-10   -0.761778
dtype: float64

@jreback jreback closed this as completed Apr 25, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant