pandas.read_stata

pandas 3.1.1 · Input and output · function

Load Stata data and optionally decode labeled values into categories.

Call syntax

pd.read_stata(…) Full signature
pd.read_stata(
    filepath_or_buffer,
    *,
    convert_dates=True,
    convert_categoricals=True,
    index_col=None,
    convert_missing=False,
    preserve_dtypes=True,
    columns=None,
    order_categoricals=True,
    chunksize=None,
    iterator=False,
    compression='infer',
    storage_options=None,
)

Run the example

Edit the example and select Run Python to see the result.

Parameters

ParameterRequirementAccepted values and behavior
filepath_or_buffer Required
Positional or keyword
str, path object or file-like object
convert_dates Optional
Keyword only
Default True
bool

Choose which supported values are converted to dates while reading.

convert_categoricals Optional
Keyword only
Default True
bool
index_col Optional
Keyword only
Default None
str

Identify the column or columns whose values should become the row index.

convert_missing Optional
Keyword only
Default False
bool
preserve_dtypes Optional
Keyword only
Default True
bool
columns Optional
Keyword only
Default None
list or None

Supply column labels or control how columns are handled.

order_categoricals Optional
Keyword only
Default True
bool
chunksize Optional
Keyword only
Default None
int

Set how many rows to read or write in each batch.

iterator Optional
Keyword only
Default False
bool

Request an iterable reader so data can be consumed in pieces.

compression Optional
Keyword only
Default 'infer'
str or dict

Choose whether and how to compress or decompress data.

storage_options Optional
Keyword only
Default None
dict

Pass storage-backend options such as connection settings or HTTP headers.

Returns

DataFrame, pandas.api.typing.StataReader