Skip to content

QST:Time index problem in version 1.1.0 #35819

Closed
@maozi07

Description

@maozi07
  • I have searched the [pandas] tag on StackOverflow for similar questions.

  • I have asked my usage related question on StackOverflow.


Question about pandas

Note: If you'd still like to submit a question, please read this guide detailing how to provide the necessary information for us to reproduce your question.
I'm using pandas 1.1.0 on macos, python:3.7
As below it's weird, when I select time larger than 2020/03/01 it's rise error, but if it's 2019, all things go right
I'v tried make some random data, but can't reproduce
I don't konw it's something wrong with my data or a pandas bug with version 1.1.0(it's ok in version 1.0.1)
Very appreciate for someone can give help

pd.__version__
'1.1.0'
df.index
DatetimeIndex(['2020-07-02 08:55:59', '2020-07-03 07:59:32',
               '2020-07-06 06:57:38', '2020-07-11 09:25:35',
               '2020-07-09 10:02:25', '2020-07-13 07:10:12',
               '2020-07-16 07:58:52', '2020-07-17 10:46:43',
               '2020-07-18 08:00:36', '2020-07-22 11:47:43',
               ...
               '2020-08-01 07:58:25', '2020-08-01 07:59:05',
               '2020-08-01 07:58:50', '2020-08-01 07:57:50',
               '2020-07-29 02:50:06', '2020-08-01 07:58:20',
               '2020-08-01 07:58:30', '2020-08-01 07:58:21',
               '2020-08-01 07:59:08', '2020-08-01 07:58:53'],
              dtype='datetime64[ns]', name='sub_time', length=4715513, freq=None)

df['20200701':]
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-54-0be901d6256c> in <module>
----> 1 df['20200701':]

/opt/anaconda3/lib/python3.7/site-packages/pandas/core/frame.py in __getitem__(self, key)
   2880             # either we have a slice or we have a string that can be converted
   2881             #  to a slice for partial-string date indexing
-> 2882             return self._slice(indexer, axis=0)
   2883 
   2884         # Do we have a (boolean) DataFrame?

/opt/anaconda3/lib/python3.7/site-packages/pandas/core/generic.py in _slice(self, slobj, axis)
   3546         Slicing with this method is *always* positional.
   3547         """
-> 3548         assert isinstance(slobj, slice), type(slobj)
   3549         axis = self._get_block_manager_axis(axis)
   3550         result = self._constructor(self._mgr.get_slice(slobj, axis=axis))

AssertionError: <class 'numpy.ndarray'>

df['20190701':]

                                     A         B  ...    C    D
a_time                                                   ...                    
2020-07-02 08:55:59              aa  cc  ...  22  1.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    DatetimeDatetime data dtypeDuplicate ReportDuplicate issue or pull requestIndexingRelated to indexing on series/frames, not to indexes themselvesRegressionFunctionality that used to work in a prior pandas version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions