Skip to content

read_spss only accepts str, not Path #33666

Closed
@cantudiaz

Description

@cantudiaz

pandas documentation states that the read_spss function can take either strings or pathlih.Path as input. It probably has something to do with pyreadstat.read_sav.

Example:

>>> import pandas as pd
>>> from pathlib import Path
>>> filepath = Path("Documents/test.sav")
>>> pd.read_spss(filepath)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/anaconda3/envs/env/lib/python3.7/site-packages/pandas/io/spss.py", line 43, in read_spss
    path, usecols=usecols, apply_value_formats=convert_categoricals
TypeError: Argument 'filename_path' has incorrect type (expected str, got PosixPath)

Libraries versions:

INSTALLED VERSIONS
------------------
commit           : None
python           : 3.7.7.final.0
python-bits      : 64
OS               : Linux
OS-release       : 5.0.0-32-generic
machine          : x86_64
processor        : x86_64
byteorder        : little
LC_ALL           : None
LANG             : en_US.UTF-8
LOCALE           : en_US.UTF-8

pandas           : 1.0.3
numpy            : 1.18.3
pytz             : 2019.3
dateutil         : 2.8.1
pip              : 19.0.3
setuptools       : 46.1.3.post20200330
Cython           : None
pytest           : 4.3.1
hypothesis       : None
sphinx           : None
blosc            : None
feather          : None
xlsxwriter       : None
lxml.etree       : None
html5lib         : None
pymysql          : None
psycopg2         : None
jinja2           : 2.11.2
IPython          : 7.13.0
pandas_datareader: None
bs4              : None
bottleneck       : None
fastparquet      : None
gcsfs            : None
lxml.etree       : None
matplotlib       : 3.0.3
numexpr          : None
odfpy            : None
openpyxl         : None
pandas_gbq       : None
pyarrow          : None
pytables         : None
pytest           : 4.3.1
pyxlsb           : None
s3fs             : None
scipy            : 1.2.3
sqlalchemy       : None
tables           : None
tabulate         : None
xarray           : None
xlrd             : None
xlwt             : None
xlsxwriter       : None
numba            : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    API - ConsistencyInternal Consistency of API/BehaviorIO DataIO issues that don't fit into a more specific label

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions