Skip to content

Pandas 15.0: TypeError: can't pickle busdaycalendar objects #8591

Closed
@bazeli

Description

@bazeli

Using the documentation's own CustomBusinessDay example, you can no longer save objects with a CustomBusinessDay frequency to an HDF store in Pandas 15.0 Final (but worked in 14.1):

import pandas as pd
import numpy as np
from pandas.tseries.offsets import CustomBusinessDay
from datetime import datetime
weekmask_egypt = 'Sun Mon Tue Wed Thu'
holidays = ['2012-05-01', datetime(2013, 5, 1), np.datetime64('2014-05-01')]
bday_egypt = CustomBusinessDay(holidays=holidays, weekmask=weekmask_egypt)
dt = datetime(2013, 4, 30)
dts = pd.date_range(dt, periods=5, freq=bday_egypt)
s = (pd.Series(dts.weekday, dts).map(pd.Series('Mon Tue Wed Thu Fri Sat Sun'.split())))
store = pd.HDFStore('test.hdf')
store.put('test',s)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/pandas/io/pytables.py", line 831, in put
    self._write_to_group(key, value, append=append, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/pandas/io/pytables.py", line 1280, in _write_to_group
    s.write(obj=value, append=append, complib=complib, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/pandas/io/pytables.py", line 2557, in write
    self.write_index('index', obj.index)
  File "/usr/local/lib/python2.7/site-packages/pandas/io/pytables.py", line 2316, in write_index
    node._v_attrs.freq = index.freq
  File "/usr/local/lib/python2.7/site-packages/tables/attributeset.py", line 455, in __setattr__
    self._g__setattr(name, value)
  File "/usr/local/lib/python2.7/site-packages/tables/attributeset.py", line 397, in _g__setattr
    self._g_setattr(self._v_node, name, stvalue)
  File "hdf5extension.pyx", line 700, in tables.hdf5extension.AttributeSet._g_setattr (tables/hdf5extension.c:6623)
  File "/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy_reg.py", line 70, in _reduce_ex
    raise TypeError, "can't pickle %s objects" % base.__name__
TypeError: can't pickle busdaycalendar objects


>>> pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 2.7.8.final.0
python-bits: 64
OS: Darwin
OS-release: 13.4.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8

pandas: 0.15.0
nose: 1.3.1
Cython: 0.20.2
numpy: 1.8.1
scipy: 0.14.0
statsmodels: None
IPython: 2.2.0
sphinx: None
patsy: None
dateutil: 2.2
pytz: 2014.4
bottleneck: 0.8.0
tables: 3.1.1
numexpr: 2.4
matplotlib: 1.3.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
rpy2: None
sqlalchemy: None
pymysql: None
psycopg2: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugCompatpandas objects compatability with Numpy or Python functionsFrequencyDateOffsets

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions