Skip to content

BUG: offsets are now unhashable #37267

Closed
@dhirschfeld

Description

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


As discussed on gitter, this was apparently an unindended consequence of #34227

image
https://gitter.im/pydata/pandas?at=5f8d8a106c8d484be294872f

Code Sample, a copy-pastable example

>>> import pandas as pd
>>> hash(pd.offsets.Day())
Traceback (most recent call last):
  File "C:\Users\dhirschf\envs\dev\lib\site-packages\IPython\core\interactiveshell.py", line 3417, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-46-d78c0d3ee4ad>", line 1, in <module>
    hash(pd.offsets.Day())
TypeError: unhashable type: 'pandas._libs.tslibs.offsets.Day'

Problem description

My code relied on the hashability of offsets and so this broke my code and has so far prevented me upgrading to the latest pandas

Expected Output

Output of pd.show_versions()

>>> pd.show_versions()

INSTALLED VERSIONS
------------------
commit           : db08276bc116c438d3fdee492026f8223584c477
python           : 3.7.7.final.0
python-bits      : 64
OS               : Windows
OS-release       : 10
Version          : 10.0.17763
machine          : AMD64
processor        : Intel64 Family 6 Model 58 Stepping 0, GenuineIntel
byteorder        : little
LC_ALL           : None
LANG             : None
LOCALE           : None.None
pandas           : 1.1.3
numpy            : 1.19.1
pytz             : 2020.1
dateutil         : 2.8.1
pip              : 20.2.4
setuptools       : 50.3.0.post20201006
Cython           : 0.29.21
pytest           : 6.1.1
hypothesis       : 5.37.3
sphinx           : 3.2.1
blosc            : 1.9.2
feather          : None
xlsxwriter       : 1.3.7
lxml.etree       : 4.6.0
html5lib         : 1.1
pymysql          : 0.10.1
psycopg2         : 2.8.6 (dt dec pq3 ext lo64)
jinja2           : 2.11.2
IPython          : 7.18.1
pandas_datareader: None
bs4              : 4.9.3
bottleneck       : 1.3.2
fsspec           : 0.8.4
fastparquet      : None
gcsfs            : None
matplotlib       : 3.3.2
numexpr          : 2.7.1
odfpy            : None
openpyxl         : 3.0.5
pandas_gbq       : None
pyarrow          : 1.0.1
pytables         : None
pyxlsb           : None
s3fs             : None
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrequencyDateOffsetsRegressionFunctionality that used to work in a prior pandas version

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions