Skip to content

Commit 53606ff

Browse files
Liam3851jreback
authored andcommitted
BUG: Compat for pre-0.20 TimedeltaIndex and Float64Index pickles pandas-dev#19939 (pandas-dev#19943)
1 parent 0bfb61b commit 53606ff

File tree

5 files changed

+22
-2
lines changed

5 files changed

+22
-2
lines changed

doc/source/whatsnew/v0.23.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,7 @@ I/O
957957
- :class:`Interval` now supported in :func:`DataFrame.to_excel` for all Excel file types (:issue:`19242`)
958958
- :class:`Timedelta` now supported in :func:`DataFrame.to_excel` for all Excel file types (:issue:`19242`, :issue:`9155`, :issue:`19900`)
959959
- Bug in :meth:`pandas.io.stata.StataReader.value_labels` raising an ``AttributeError`` when called on very old files. Now returns an empty dict (:issue:`19417`)
960+
- Bug in :func:`read_pickle` when unpickling objects with :class:`TimedeltaIndex` or :class:`Float64Index` created with pandas prior to version 0.20 (:issue:`19939`)
960961

961962
Plotting
962963
^^^^^^^^

pandas/compat/pickle_compat.py

+6
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ def load_reduce(self):
113113
# 19269, arrays moving
114114
('pandas.core.categorical', 'Categorical'):
115115
('pandas.core.arrays', 'Categorical'),
116+
117+
# 19939, add timedeltaindex, float64index compat from 15998 move
118+
('pandas.tseries.tdi', 'TimedeltaIndex'):
119+
('pandas.core.indexes.timedeltas', 'TimedeltaIndex'),
120+
('pandas.indexes.numeric', 'Float64Index'):
121+
('pandas.core.indexes.numeric', 'Float64Index'),
116122
}
117123

118124

Binary file not shown.
Binary file not shown.

pandas/tests/io/generate_legacy_storage_files.py

+15-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
from pandas import (Series, DataFrame, Panel,
4141
SparseSeries, SparseDataFrame,
4242
Index, MultiIndex, bdate_range, to_msgpack,
43-
date_range, period_range,
43+
date_range, period_range, timedelta_range,
4444
Timestamp, NaT, Categorical, Period)
4545
from pandas.tseries.offsets import (
4646
DateOffset, Hour, Minute, Day,
@@ -116,7 +116,18 @@ def create_data():
116116

117117
index = dict(int=Index(np.arange(10)),
118118
date=date_range('20130101', periods=10),
119-
period=period_range('2013-01-01', freq='M', periods=10))
119+
period=period_range('2013-01-01', freq='M', periods=10),
120+
float=Index(np.arange(10, dtype=np.float64)),
121+
uint=Index(np.arange(10, dtype=np.uint64)),
122+
timedelta=timedelta_range('00:00:00', freq='30T', periods=10))
123+
124+
if _loose_version >= LooseVersion('0.18'):
125+
from pandas import RangeIndex
126+
index['range'] = RangeIndex(10)
127+
128+
if _loose_version >= LooseVersion('0.21'):
129+
from pandas import interval_range
130+
index['interval'] = interval_range(0, periods=10)
120131

121132
mi = dict(reg2=MultiIndex.from_tuples(
122133
tuple(zip(*[[u'bar', u'bar', u'baz', u'baz', u'foo',
@@ -276,6 +287,8 @@ def create_msgpack_data():
276287
del data['frame']['cat_onecol']
277288
del data['frame']['cat_and_float']
278289
del data['scalars']['period']
290+
del data['index']['interval']
291+
del data['offsets']
279292
return _u(data)
280293

281294

0 commit comments

Comments
 (0)