partial slicing FAILS with a datetimeindex
See original GitHub issueHi,
I have a simple dataframe with a multiindex.
stats.index.names
Out[67]: FrozenList([u'day', u'category'])
day is a time variable, category is a string.
stats.index.inferred_type
Out[69]: 'mixed'
stats.index.dtype_str
Out[68]: 'object'
if I type
idx=pd.IndexSlice
stats.loc[idx['2015-01-01',:],:]
I get the correct slice at ‘2015-01-01’, that is all the observations for all the categories on that day.
If I type
idx=pd.IndexSlice
stats.loc[idx['2015',:],:]
I get back (almost) all my observations, even for years other than 2015.
What can be the problem here? I cannot paste the data unfortunately but I am happy to help in any way.
Thanks
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Wrong DateTimeIndex slicing when freq is None #2389 - GitHub
When Dask DataFrame is constructed from Pandas DataFrame with DateTimeIndex but freq is None, dask loc slicing fails.
Read more >How to subscript / slice / select a datetime index dataframe ...
You can continue to subscript by partial date string to specify a date range, e.g. df.loc['2020-01'] # for date range within a month....
Read more >Pandas Tutorial-Indexing, Slicing, Date & Times - Medium
We can slice partial datetime strings by providing a Start and Stop string separated by a Colon : . This Slices all the...
Read more >Indexing time series data in pandas - wrighters.io
In pandas, a DatetimeIndex is used to provide indexing for pandas Series and ... Index types first, then talk about the basics of...
Read more >Indexing and selecting data — pandas 1.5.2 documentation
In this section, we will focus on the final point: namely, how to slice, dice, and generally get and set subsets of pandas...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@randomgambit But anyway, thanks for reporting!
damn I was proud of finding a cool bug, you destroyed my dreams