pandas.read_spss

pandas 3.1.1 · Input and output · function

Load a DataFrame from an SPSS data file.

Call syntax

pd.read_spss(path, usecols=None, convert_categoricals=True, dtype_backend=…, **kwargs)

Inspect the call

Run this code to inspect the callable and its parameters. Its data, backend, or environment is needed to execute the operation itself.

Parameters

ParameterRequirementAccepted values and behavior
path Required
Positional or keyword
str or Path

Supply a file path or file-like object where supported.

usecols Optional
Positional or keyword
Default None
list-like

Select a subset of source columns by name, position, or a callable.

convert_categoricals Optional
Positional or keyword
Default True
bool
dtype_backend Optional
Positional or keyword
{'numpy_nullable', 'pyarrow'}

Choose nullable NumPy-backed dtypes or Arrow-backed dtypes.

**kwargs Optional
Additional keyword arguments

Returns

DataFrame

Example for a local Python session

import pandas as pd
from pathlib import Path
from tempfile import TemporaryDirectory
import pyreadstat

with TemporaryDirectory() as folder:
    path = Path(folder) / "orders.sav"
    pyreadstat.write_sav(pd.DataFrame({"units": [2, 5]}), path)
    print(pd.read_spss(path, usecols=["units"]))