@@ -4282,6 +4282,49 @@ def test_select_filter_corner(self):
42824282 result = store .select ('frame' , [crit ])
42834283 tm .assert_frame_equal (result , df .loc [:, df .columns [:75 :2 ]])
42844284
4285+ def test_path_pathlib (self ):
4286+ df = tm .makeDataFrame ()
4287+
4288+ result = tm .round_trip_pathlib (
4289+ lambda p : df .to_hdf (p , 'df' ),
4290+ lambda p : pd .read_hdf (p , 'df' ))
4291+ tm .assert_frame_equal (df , result )
4292+
4293+ @pytest .mark .xfail (reason = 'pathlib currently doesnt work with HDFStore' )
4294+ def test_path_pathlib_hdfstore (self ):
4295+ df = tm .makeDataFrame ()
4296+
4297+ def writer (path ):
4298+ with pd .HDFStore (path ) as store :
4299+ df .to_hdf (store , 'df' )
4300+
4301+ def reader (path ):
4302+ with pd .HDFStore (path ) as store :
4303+ pd .read_hdf (store , 'df' )
4304+ result = tm .round_trip_pathlib (writer , reader )
4305+ tm .assert_frame_equal (df , result )
4306+
4307+ def test_pickle_path_localpath (self ):
4308+ df = tm .makeDataFrame ()
4309+ result = tm .round_trip_pathlib (
4310+ lambda p : df .to_hdf (p , 'df' ),
4311+ lambda p : pd .read_hdf (p , 'df' ))
4312+ tm .assert_frame_equal (df , result )
4313+
4314+ @pytest .mark .xfail (reason = 'localpath currently doesnt work with HDFStore' )
4315+ def test_path_localpath_hdfstore (self ):
4316+ df = tm .makeDataFrame ()
4317+
4318+ def writer (path ):
4319+ with pd .HDFStore (path ) as store :
4320+ df .to_hdf (store , 'df' )
4321+
4322+ def reader (path ):
4323+ with pd .HDFStore (path ) as store :
4324+ pd .read_hdf (store , 'df' )
4325+ result = tm .round_trip_localpath (writer , reader )
4326+ tm .assert_frame_equal (df , result )
4327+
42854328 def _check_roundtrip (self , obj , comparator , compression = False , ** kwargs ):
42864329
42874330 options = {}
0 commit comments