Skip to content

Commit 9eed2e4

Browse files
committed
TST: add mixed-type panels & frames to generate_legacy_pickles
Don't generate them for pre-0.14.1 as they cannot be unpickled.
1 parent 34cecd8 commit 9eed2e4

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.

pandas/io/tests/generate_legacy_pickles.py

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
""" self-contained to write legacy pickle files """
22
from __future__ import print_function
33

4+
45
def _create_sp_series():
56

67
import numpy as np
@@ -53,6 +54,7 @@ def _create_sp_frame():
5354
def create_data():
5455
""" create the pickle data """
5556

57+
from distutils.version import LooseVersion
5658
import numpy as np
5759
import pandas
5860
from pandas import (Series,TimeSeries,DataFrame,Panel,
@@ -92,13 +94,23 @@ def create_data():
9294
index=MultiIndex.from_tuples(tuple(zip(*[['bar','bar','baz','baz','baz'],
9395
['one','two','one','two','three']])),
9496
names=['first','second'])),
95-
dup = DataFrame(np.arange(15).reshape(5, 3).astype(np.float64),
96-
columns=['A', 'B', 'A']))
97+
dup=DataFrame(np.arange(15).reshape(5, 3).astype(np.float64),
98+
columns=['A', 'B', 'A']))
9799
panel = dict(float = Panel(dict(ItemA = frame['float'], ItemB = frame['float']+1)),
98100
dup = Panel(np.arange(30).reshape(3, 5, 2).astype(np.float64),
99101
items=['A', 'B', 'A']))
100102

103+
if LooseVersion(pandas.__version__) >= '0.14.1':
104+
# Pre-0.14.1 versions generated non-unpicklable mixed-type frames and
105+
# panels if their columns/items were non-unique.
106+
mixed_dup_df = DataFrame(data)
107+
mixed_dup_df.columns = list("ABCDA")
108+
109+
mixed_dup_panel = Panel(dict(ItemA=frame['float'], ItemB=frame['int']))
110+
mixed_dup_panel.items = ['ItemA', 'ItemA']
101111

112+
frame['mixed_dup'] = mixed_dup_df
113+
panel['mixed_dup'] = mixed_dup_panel
102114

103115
return dict( series = series,
104116
frame = frame,

0 commit comments

Comments
 (0)