Skip to content

pd.HDFStore doesn't accept pathlib objects #14705

Closed
@TomAugspurger

Description

@TomAugspurger

Code Sample, a copy-pastable example if possible

# Your code here
In [1]: from pathlib import Path

In [2]: pd.HDFStore(Path('store.h5'))
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-7a495ee2d608> in <module>()
----> 1 pd.HDFStore(Path('store.h5'))

/Users/tom.augspurger/Envs/py3/lib/python3.5/site-packages/pandas/pandas/io/pytables.py in __init__(self, path, mode, complevel, complib, fletcher32, **kwargs)
    446         self._fletcher32 = fletcher32
    447         self._filters = None
--> 448         self.open(mode=mode, **kwargs)
    449
    450     @property

/Users/tom.augspurger/Envs/py3/lib/python3.5/site-packages/pandas/pandas/io/pytables.py in open(self, mode, **kwargs)
    585
    586         try:
--> 587             self._handle = tables.open_file(self._path, self._mode, **kwargs)
    588         except (IOError) as e:  # pragma: no cover
    589             if 'can not be written' in str(e):

/Users/tom.augspurger/Envs/py3/lib/python3.5/site-packages/tables/file.py in open_file(filename, mode, title, root_uep, filters, **kwargs)
    316
    317     # Finally, create the File instance, and return it
--> 318     return File(filename, mode, title, root_uep, filters, **kwargs)
    319
    320 openFile = previous_api(open_file)

/Users/tom.augspurger/Envs/py3/lib/python3.5/site-packages/tables/file.py in __init__(self, filename, mode, title, root_uep, filters, **kwargs)
    782
    783         # Now, it is time to initialize the File extension
--> 784         self._g_new(filename, mode, **params)
    785
    786         # Check filters and set PyTables format version for new files.

tables/hdf5extension.pyx in tables.hdf5extension.File._g_new (tables/hdf5extension.c:3781)()

tables/utilsextension.pyx in tables.utilsextension.encode_filename (tables/utilsextension.c:5345)()

TypeError: Expected bytes, got PosixPath

Expected Output

same as str for path

xref #11033 for the original Pathlib implementation
xref #13823 for fspath

Metadata

Metadata

Assignees

No one assigned

    Labels

    IO DataIO issues that don't fit into a more specific labelIO HDF5read_hdf, HDFStoregood first issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions