Skip to content

.loc slice with datetime string with DataFrame of length 1 gives an empty DataFrame #16071

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
cpaulik opened this issue Apr 20, 2017 · 0 comments
Labels
Bug Datetime Datetime data dtype Indexing Related to indexing on series/frames, not to indexes themselves
Milestone

Comments

@cpaulik
Copy link

cpaulik commented Apr 20, 2017

I've already raised the problem at #13929 (comment) but it turned out to be a different issue.

The following test code illustrates the problem

import pandas as pd
from pandas.util import testing as tm

from datetime import datetime
df = pd.DataFrame(columns=['1'],
                  index=pd.date_range('2016-10-01T00:00:00',
                                      '2016-10-01T23:59:59'))
df_sliced_dt = df.loc[datetime(2016,10,1):]
tm.assert_frame_equal(df, df_sliced_dt)

df = pd.DataFrame(columns=['1'],
                  index=pd.date_range('2016-10-01T00:00:00',
                                      '2016-10-01T23:59:59'))
df_sliced_str = df.loc['2016-10-01T00:00:00':]
tm.assert_frame_equal(df, df_sliced_str)
@jreback jreback added Bug Difficulty Intermediate Indexing Related to indexing on series/frames, not to indexes themselves Datetime Datetime data dtype labels Apr 20, 2017
@jreback jreback modified the milestones: Next Major Release, 0.20.0 Apr 20, 2017
pcluo pushed a commit to pcluo/pandas that referenced this issue May 22, 2017
closes pandas-dev#16071

Author: Christoph Paulik <[email protected]>

Closes pandas-dev#16072 from cpaulik/fix-length-1-loc-slice-GH16071 and squashes the following commits:

9154732 [Christoph Paulik] BUG: Fix length 1 .loc slicing with datetime string GH16071
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Datetime Datetime data dtype Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants