-
-
Notifications
You must be signed in to change notification settings - Fork 19k
Closed
Labels
BlockerBlocking issue or pull request for an upcoming releaseBlocking issue or pull request for an upcoming releaseBugIndexingRelated to indexing on series/frames, not to indexes themselvesRelated to indexing on series/frames, not to indexes themselvesPeriodPeriod data typePeriod data typeRegressionFunctionality that used to work in a prior pandas versionFunctionality that used to work in a prior pandas version
Milestone
Description
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
Code Sample, a copy-pastable example
>>> import pandas as pd
>>>
>>> pd.__version__
'1.1.0.dev0+1466.ga3477c769'
>>>
>>> index = pd.period_range(start="2000", periods=20, freq="B")
>>> series = pd.Series(range(20), index=index)
>>>
>>> series.index
PeriodIndex(['2000-01-03', '2000-01-04', '2000-01-05', '2000-01-06',
'2000-01-07', '2000-01-10', '2000-01-11', '2000-01-12',
'2000-01-13', '2000-01-14', '2000-01-17', '2000-01-18',
'2000-01-19', '2000-01-20', '2000-01-21', '2000-01-24',
'2000-01-25', '2000-01-26', '2000-01-27', '2000-01-28'],
dtype='period[B]', freq='B')
>>>
>>> series.loc["2000-01-14"]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\simon\pandas\pandas\core\indexing.py", line 871, in __getitem__
return self._getitem_axis(maybe_callable, axis=axis)
File "C:\Users\simon\pandas\pandas\core\indexing.py", line 1102, in _getitem_axis
return self._get_label(key, axis=axis)
File "C:\Users\simon\pandas\pandas\core\indexing.py", line 1051, in _get_label
return self.obj.xs(label, axis=axis)
File "C:\Users\simon\pandas\pandas\core\generic.py", line 3512, in xs
loc = self.index.get_loc(key)
File "C:\Users\simon\pandas\pandas\core\indexes\period.py", line 519, in get_loc
raise KeyError(key)
KeyError: '2000-01-14'
>>>
Problem description
regression in #31172 (i.e. not yet released)
9a211aa is the first bad commit
commit 9a211aa
Author: jbrockmendel jbrockmendel@gmail.com
Date: Sat Jan 25 08:07:15 2020 -0800
BUG: inconsistency between PeriodIndex.get_value vs get_loc (#31172)
Expected Output
>>> import pandas as pd
>>>
>>> pd.__version__
'1.0.3'
>>>
>>> index = pd.period_range(start="2000", periods=20, freq="B")
>>> series = pd.Series(range(20), index=index)
>>>
>>> series.index
PeriodIndex(['2000-01-03', '2000-01-04', '2000-01-05', '2000-01-06',
'2000-01-07', '2000-01-10', '2000-01-11', '2000-01-12',
'2000-01-13', '2000-01-14', '2000-01-17', '2000-01-18',
'2000-01-19', '2000-01-20', '2000-01-21', '2000-01-24',
'2000-01-25', '2000-01-26', '2000-01-27', '2000-01-28'],
dtype='period[B]', freq='B')
>>>
>>> series.loc["2000-01-14"]
9
>>>
Output of pd.show_versions()
[paste the output of pd.show_versions()
here leaving a blank line after the details tag]
Metadata
Metadata
Assignees
Labels
BlockerBlocking issue or pull request for an upcoming releaseBlocking issue or pull request for an upcoming releaseBugIndexingRelated to indexing on series/frames, not to indexes themselvesRelated to indexing on series/frames, not to indexes themselvesPeriodPeriod data typePeriod data typeRegressionFunctionality that used to work in a prior pandas versionFunctionality that used to work in a prior pandas version
Type
Projects
Relationships
Development
Select code repository
Activity
TomAugspurger commentedon Jun 12, 2020
@jbrockmendel do you have time to look into this in the next week or two? If not I can take a look next week.
jbrockmendel commentedon Jun 12, 2020
I'm taking a break for a little while, can look at this when i get back
TomAugspurger commentedon Jun 12, 2020
No worries. Enjoy the break.
BUG: Fixed regression in PeriodIndex loc
BUG: Fixed regression in PeriodIndex loc (#34736)