|
16 | 16 | date_range, timedelta_range, Index, DatetimeIndex,
|
17 | 17 | isnull)
|
18 | 18 |
|
19 |
| -from pandas.compat import is_platform_windows, PY3, PY35, BytesIO |
| 19 | +from pandas.compat import is_platform_windows, PY3, PY35, BytesIO, text_type |
20 | 20 | from pandas.io.formats.printing import pprint_thing
|
21 | 21 |
|
22 | 22 | tables = pytest.importorskip('tables')
|
@@ -2920,6 +2920,27 @@ def test_store_index_name_with_tz(self):
|
2920 | 2920 | recons = store['frame']
|
2921 | 2921 | tm.assert_frame_equal(recons, df)
|
2922 | 2922 |
|
| 2923 | + @pytest.mark.parametrize('table_format', ['table', 'fixed']) |
| 2924 | + def test_store_index_name_numpy_str(self, table_format): |
| 2925 | + # GH #13492 |
| 2926 | + idx = pd.Index(pd.to_datetime([datetime.date(2000, 1, 1), |
| 2927 | + datetime.date(2000, 1, 2)]), |
| 2928 | + name=u('cols\u05d2')) |
| 2929 | + idx1 = pd.Index(pd.to_datetime([datetime.date(2010, 1, 1), |
| 2930 | + datetime.date(2010, 1, 2)]), |
| 2931 | + name=u('rows\u05d0')) |
| 2932 | + df = pd.DataFrame(np.arange(4).reshape(2, 2), columns=idx, index=idx1) |
| 2933 | + |
| 2934 | + # This used to fail, returning numpy strings instead of python strings. |
| 2935 | + with ensure_clean_path(self.path) as path: |
| 2936 | + df.to_hdf(path, 'df', format=table_format) |
| 2937 | + df2 = read_hdf(path, 'df') |
| 2938 | + |
| 2939 | + assert_frame_equal(df, df2, check_names=True) |
| 2940 | + |
| 2941 | + assert type(df2.index.name) == text_type |
| 2942 | + assert type(df2.columns.name) == text_type |
| 2943 | + |
2923 | 2944 | def test_store_series_name(self):
|
2924 | 2945 | df = tm.makeDataFrame()
|
2925 | 2946 | series = df['A']
|
|
0 commit comments