statsmodels.iolib.foreign.StataWriter¶
-
class
statsmodels.iolib.foreign.StataWriter(fname, data, convert_dates=None, encoding='latin-1', byteorder=None)[source]¶ A class for writing Stata binary dta files from array-like objects
- Parameters
- fname
filepathorbuffer Where to save the dta file.
- dataarray_like
Array-like input to save. Pandas objects are also accepted.
- convert_dates
dict Dictionary mapping column of datetime types to the stata internal format that you want to use for the dates. Options are ‘tc’, ‘td’, ‘tm’, ‘tw’, ‘th’, ‘tq’, ‘ty’. Column can be either a number or a name.
- encoding
str Default is latin-1. Note that Stata does not support unicode.
- byteorder
str Can be “>”, “<”, “little”, or “big”. The default is None which uses sys.byteorder
- fname
- Returns
- writer
StataWriterinstance The StataWriter instance has a write_file method, which will write the file to the given fname.
- writer
Examples
>>> writer = StataWriter('./data_file.dta', data) >>> writer.write_file()
Or with dates
>>> writer = StataWriter('./date_data_file.dta', date, {2 : 'tw'}) >>> writer.write_file()
Methods
Properties