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