Skip to content

BUG: PeriodIndex.dtype comparison with string exhibits contradiction #37265

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
3 tasks done
hickmanw opened this issue Oct 19, 2020 · 1 comment · Fixed by #37270
Closed
3 tasks done

BUG: PeriodIndex.dtype comparison with string exhibits contradiction #37265

hickmanw opened this issue Oct 19, 2020 · 1 comment · Fixed by #37270
Labels
Dtype Conversions Unexpected or buggy dtype conversions Regression Functionality that used to work in a prior pandas version
Milestone

Comments

@hickmanw
Copy link

  • 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.


Code Sample

index = pd.period_range(start='01Jan2019', end='01Dec2019', freq='M')
string = "period[M]"
index.dtype == string  # True
index.dtype != string  # also True

Problem description

PeriodIndex.dtype is both __eq__ and __ne__ to the string representation of its frequency. I suspect that comparing the dtype to a string is not recommended, but the contradiction seemed worth reporting. I don't know when this was introduced, but it did not occur in 0.25.3.

Expected Output

One of the two comparisons to evaluate to False.

Output of pd.show_versions()

INSTALLED VERSIONS

commit : a34a408
python : 3.8.6.final.0
python-bits : 64
OS : Linux
OS-release : 4.14.198-152.320.amzn2.x86_64
Version : #1 SMP Wed Sep 23 23:57:28 UTC 2020
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : en_US.UTF-8
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 1.2.0.dev0+830.ga34a408e8
numpy : 1.19.2
pytz : 2020.1
dateutil : 2.8.1
pip : 20.2.4
setuptools : 49.6.0.post20201009
Cython : 0.29.21
pytest : 6.1.1
hypothesis : 5.37.3
sphinx : 3.2.1
blosc : None
feather : None
xlsxwriter : 1.3.7
lxml.etree : 4.6.1
html5lib : 1.1
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.18.1
pandas_datareader: None
bs4 : 4.9.3
bottleneck : 1.3.2
fsspec : 0.8.4
fastparquet : 0.4.1
gcsfs : 0.7.1
matplotlib : 3.3.2
numexpr : 2.7.1
odfpy : None
openpyxl : 3.0.5
pandas_gbq : None
pyarrow : 1.0.1
pyxlsb : None
s3fs : 0.4.2
scipy : 1.5.2
sqlalchemy : 1.3.20
tables : 3.6.1
tabulate : 0.8.7
xarray : 0.16.1
xlrd : 1.2.0
xlwt : 1.3.0
numba : 0.51.2

@hickmanw hickmanw added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Oct 19, 2020
@dsaxton dsaxton added Dtype Conversions Unexpected or buggy dtype conversions Regression Functionality that used to work in a prior pandas version and removed Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Oct 20, 2020
@dsaxton
Copy link
Member

dsaxton commented Oct 20, 2020

Thanks, this is a regression due to #34590

cc @jbrockmendel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dtype Conversions Unexpected or buggy dtype conversions Regression Functionality that used to work in a prior pandas version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants