@@ -1846,18 +1846,15 @@ def to_stata(self, fname, convert_dates=None, write_index=True,
1846
1846
data_label = None , variable_labels = None , version = 114 ,
1847
1847
convert_strl = None ):
1848
1848
"""
1849
- Converting data frame object to Stata dta format.
1849
+ Converting DataFrame object to Stata dta format.
1850
1850
1851
- Writes the Dataframe to a Stata dataset file.
1851
+ Writes the DataFrame to a Stata dataset file.
1852
1852
"dta" files contain a Stata dataset.
1853
1853
1854
1854
Parameters
1855
1855
----------
1856
- fname : path (string), buffer or path object
1857
- String, path object (pathlib.Path or py._path.local.LocalPath) or
1858
- object implementing a binary write() functions. If using a buffer
1859
- then the buffer will not be automatically closed after the file
1860
- data has been written.
1856
+ fname : str, file descriptor or pathlib.Path
1857
+ String or path to file which needs to be converted.
1861
1858
convert_dates : dict
1862
1859
Dictionary mapping columns containing datetime types to stata
1863
1860
internal format to use when writing the dates. Options are 'tc',
@@ -1899,10 +1896,6 @@ def to_stata(self, fname, convert_dates=None, write_index=True,
1899
1896
1900
1897
.. versionadded:: 0.23.0
1901
1898
1902
- Returns
1903
- ------
1904
- Stata (dta) file or StataWriter.
1905
-
1906
1899
Raises
1907
1900
------
1908
1901
NotImplementedError
@@ -1924,22 +1917,12 @@ def to_stata(self, fname, convert_dates=None, write_index=True,
1924
1917
1925
1918
Examples
1926
1919
--------
1927
- Converting dataframe with date column to Stata dta file
1928
- using the to_stata method.
1920
+ Converting DataFrame to Stata "dta" file using the to_stata method.
1929
1921
1930
- >>> dates = pd.date_range(start='2018-01-01', periods=4)
1931
- >>> df = pd.DataFrame({'date': dates,
1932
- ... 'animal': ['falcon', 'parrot', 'falcon',
1922
+ >>> df = pd.DataFrame({'animal': ['falcon', 'parrot', 'falcon',
1933
1923
... 'parrot'],
1934
- ... 'speed': [350, 18, 361, 15]}).set_index(['date',
1935
- ... 'animal'])
1924
+ ... 'speed': [350, 18, 361, 15]})
1936
1925
>>> df.to_stata('animals.dta')
1937
-
1938
- Alternatively you can create an instance of the StataWriter class
1939
-
1940
- >>> StataWriter = pd.io.stata.StataWriter
1941
- >>> writer = StataWriter('animals.dta', df)
1942
- >>> writer.write_file()
1943
1926
"""
1944
1927
kwargs = {}
1945
1928
if version not in (114 , 117 ):
0 commit comments