pandas.DataFrame.to_stata

pandas 3.1.1 · DataFrame · method

Write a DataFrame as a Stata data file.

Call syntax

DataFrame.to_stata(…) Full signature
DataFrame.to_stata(
    path,
    *,
    convert_dates=None,
    write_index=True,
    byteorder=None,
    time_stamp=None,
    data_label=None,
    variable_labels=None,
    version=114,
    convert_strl=None,
    compression='infer',
    storage_options=None,
    value_labels=None,
)

Run the example

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

Parameters

ParameterRequirementAccepted values and behavior
path Required
Positional or keyword
str, path object, or buffer

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

convert_dates Optional
Keyword only
Default None
dict

Choose which supported values are converted to dates while reading.

write_index Optional
Keyword only
Default True
bool
byteorder Optional
Keyword only
Default None
str
time_stamp Optional
Keyword only
Default None
datetime
data_label Optional
Keyword only
Default None
str
variable_labels Optional
Keyword only
Default None
dict
version Optional
Keyword only
Default 114
{114, 117, 118, 119, None}
convert_strl Optional
Keyword only
Default None
list
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.

value_labels Optional
Keyword only
Default None
dict of dicts

Returns

None