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: NotImplementedError: Prefix not defined when slicing offset with loc #46671

Closed
2 of 3 tasks
WillianFuks opened this issue Apr 6, 2022 · 1 comment · Fixed by #47547
Closed
2 of 3 tasks

BUG: NotImplementedError: Prefix not defined when slicing offset with loc #46671

WillianFuks opened this issue Apr 6, 2022 · 1 comment · Fixed by #47547
Labels
Bug Datetime Datetime data dtype Indexing Related to indexing on series/frames, not to indexes themselves Regression Functionality that used to work in a prior pandas version
Milestone

Comments

@WillianFuks
Copy link

WillianFuks commented Apr 6, 2022

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import numpy as np
import pandas as pd


d = pd.DataFrame(np.random.rand(10, 1))
d.set_index(pd.date_range('01-01-2022', periods=10), inplace=True)
d = d.asfreq(pd.DateOffset(days=1))
d.loc['2022-01-01': '2022-01-03']

Issue Description

As it seems, starting from version 1.4 onward, if the date index is of type offset then when trying to run loc operations raises NotImplementedError: Prefix not defined.

Searching on the web if people had a similar issue but couldn't find much, closest thing seems to be issue #26921.

Expected Behavior

Slicing the date index on specified date points in loc.

Installed Versions

INSTALLED VERSIONS

commit : bb1f651
python : 3.9.5.final.0
python-bits : 64
OS : Linux
OS-release : 5.13.0-39-generic
Version : #44~20.04.1-Ubuntu SMP Thu Mar 24 16:43:35 UTC 2022
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 1.4.0
numpy : 1.22.3
pytz : 2022.1
dateutil : 2.8.2
pip : 20.0.2
setuptools : 44.0.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.1
IPython : 8.2.0
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.5.1
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : None

@WillianFuks WillianFuks added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Apr 6, 2022
@phofl phofl added the Indexing Related to indexing on series/frames, not to indexes themselves label Apr 8, 2022
@phofl phofl changed the title BUG: NotImplementedError: Prefix not defined BUG: NotImplementedError: Prefix not defined when slicing offset with loc Apr 8, 2022
simonjayhawkins added a commit to simonjayhawkins/pandas that referenced this issue Jun 25, 2022
@simonjayhawkins
Copy link
Member

Thanks @WillianFuks for the report.

As it seems, starting from version 1.4 onward, if the date index is of type offset then when trying to run loc operations raises NotImplementedError: Prefix not defined.

first bad commit: [9a5da9b] REF: share _get_string_slice (#42149)

cc @jbrockmendel

@simonjayhawkins simonjayhawkins added Regression Functionality that used to work in a prior pandas version and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Jun 27, 2022
@simonjayhawkins simonjayhawkins added this to the 1.4.4 milestone Jun 27, 2022
@simonjayhawkins simonjayhawkins added the Datetime Datetime data dtype label Jun 27, 2022
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 Regression Functionality that used to work in a prior pandas version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants