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