string, path object (pathlib.Path or py._path.local.LocalPath) or object implementing a binary write() functions. If using a buffer then the buffer will not be automatically closed after the file is written.
Input to save
Dictionary mapping columns containing datetime types to stata internal format to use when writing the dates. Options are 'tc', 'td', 'tm', 'tw', 'th', 'tq', 'ty'. Column can be either an integer or a name. Datetime columns that do not have a conversion type specified will be converted to 'tc'. Raises NotImplementedError if a datetime column has timezone information
Write the index to Stata dataset.
Can be ">", "<", "little", or "big". default is :None:None:`sys.byteorder`
A datetime to use as file creation date. Default is the current time
A label for the data set. Must be 80 characters or smaller.
Dictionary containing columns as keys and variable labels as values. Each label must be 80 characters or smaller.
For on-the-fly compression of the output data. If 'infer' and 'fname' path-like, then detect compression from the following extensions: '.gz', '.bz2', '.zip', '.xz', or '.zst' (otherwise no compression). Set to None
for no compression. Can also be a dict with key 'method'
set to one of { 'zip'
, 'gzip'
, 'bz2'
, 'zstd'
} and other key-value pairs are forwarded to zipfile.ZipFile
, gzip.GzipFile
, bz2.BZ2File
, or zstandard.ZstdDecompressor
, respectively. As an example, the following could be passed for faster compression and to create a reproducible gzip archive: compression={'method': 'gzip', 'compresslevel': 1, 'mtime': 1}
.
Extra options that make sense for a particular storage connection, e.g. host, port, username, password, etc. For HTTP(S) URLs the key-value pairs are forwarded to urllib
as header options. For other URLs (e.g. starting with "s3://", and "gcs://") the key-value pairs are forwarded to fsspec
. Please see fsspec
and urllib
for more details.
Dictionary containing columns as keys and dictionaries of column value to labels as values. The combined length of all labels for a single variable must be 32,000 characters or smaller.
If datetimes contain timezone information
Columns listed in convert_dates are neither datetime64[ns] or datetime.datetime
Column dtype is not representable in Stata
Column listed in convert_dates is not in DataFrame
Categorical label contains more than 32,000 characters
The StataWriter instance has a write_file method, which will write the file to the given :None:None:`fname`
.
A class for writing Stata binary dta files
>>> data = pd.DataFrame([[1.0, 1]], columns=['a', 'b'])
... writer = StataWriter('./data_file.dta', data)
... writer.write_file()
Directly write a zip file >>> compression = {"method": "zip", "archive_name": "data_file.dta"} >>> writer = StataWriter('./data_file.zip', data, compression=compression) >>> writer.write_file()
Save a DataFrame with dates >>> from datetime import datetime >>> data = pd.DataFrame([[datetime(2000,1,1)]], columns=['date']) >>> writer = StataWriter('./date_data_file.dta', data, {'date' : 'tw'}) >>> writer.write_file()
See :The following pages refer to to this document either explicitly or contain code examples using this.
pandas.core.frame.DataFrame.to_stata
pandas.io.stata.StataWriter
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them