|
1 | 1 | """ self-contained to write legacy pickle files """
|
2 | 2 | from __future__ import print_function
|
3 | 3 |
|
| 4 | + |
4 | 5 | def _create_sp_series():
|
5 | 6 |
|
6 | 7 | import numpy as np
|
@@ -53,6 +54,7 @@ def _create_sp_frame():
|
53 | 54 | def create_data():
|
54 | 55 | """ create the pickle data """
|
55 | 56 |
|
| 57 | + from distutils.version import LooseVersion |
56 | 58 | import numpy as np
|
57 | 59 | import pandas
|
58 | 60 | from pandas import (Series,TimeSeries,DataFrame,Panel,
|
@@ -92,13 +94,23 @@ def create_data():
|
92 | 94 | index=MultiIndex.from_tuples(tuple(zip(*[['bar','bar','baz','baz','baz'],
|
93 | 95 | ['one','two','one','two','three']])),
|
94 | 96 | 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'])) |
97 | 99 | panel = dict(float = Panel(dict(ItemA = frame['float'], ItemB = frame['float']+1)),
|
98 | 100 | dup = Panel(np.arange(30).reshape(3, 5, 2).astype(np.float64),
|
99 | 101 | items=['A', 'B', 'A']))
|
100 | 102 |
|
| 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'] |
101 | 111 |
|
| 112 | + frame['mixed_dup'] = mixed_dup_df |
| 113 | + panel['mixed_dup'] = mixed_dup_panel |
102 | 114 |
|
103 | 115 | return dict( series = series,
|
104 | 116 | frame = frame,
|
|
0 commit comments