@@ -2920,6 +2920,33 @@ def test_store_index_name_with_tz(self):
29202920 recons = store ['frame' ]
29212921 tm .assert_frame_equal (recons , df )
29222922
2923+ def test_store_index_name_numpy_str (self ):
2924+ # GH #13492
2925+ idx = pd .Index (pd .to_datetime ([datetime .date (2000 , 1 , 1 ),
2926+ datetime .date (2000 , 1 , 2 )]),
2927+ name = 'cols' )
2928+ idx1 = pd .Index (pd .to_datetime ([datetime .date (2010 , 1 , 1 ),
2929+ datetime .date (2010 , 1 , 2 )]),
2930+ name = 'rows' )
2931+ df = pd .DataFrame (np .arange (4 ).reshape (2 , 2 ), columns = idx , index = idx1 )
2932+
2933+ # This used to fail, returning numpy strings instead of python strings.
2934+ with ensure_clean_path (self .path ) as path :
2935+ df .to_hdf (path , 'df' , format = 'fixed' )
2936+ df2 = read_hdf (path , 'df' )
2937+ assert_frame_equal (df , df2 )
2938+
2939+ assert type (df2 .index .name ) == str
2940+ assert type (df2 .columns .name ) == str
2941+
2942+ with ensure_clean_path (self .path ) as path :
2943+ df .to_hdf (path , 'df' , format = 'table' )
2944+ df2 = read_hdf (path , 'df' )
2945+ assert_frame_equal (df , df2 )
2946+
2947+ assert type (df2 .index .name ) == str
2948+ assert type (df2 .columns .name ) == str
2949+
29232950 def test_store_series_name (self ):
29242951 df = tm .makeDataFrame ()
29252952 series = df ['A' ]
0 commit comments