Skip to content

Commit 13ad994

Browse files
committed
Incorporated comments
1 parent 85b7c20 commit 13ad994

File tree

1 file changed

+7
-24
lines changed

1 file changed

+7
-24
lines changed

pandas/core/frame.py

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1856,18 +1856,15 @@ def to_stata(self, fname, convert_dates=None, write_index=True,
18561856
data_label=None, variable_labels=None, version=114,
18571857
convert_strl=None):
18581858
"""
1859-
Converting data frame object to Stata dta format.
1859+
Converting DataFrame object to Stata dta format.
18601860
1861-
Writes the Dataframe to a Stata dataset file.
1861+
Writes the DataFrame to a Stata dataset file.
18621862
"dta" files contain a Stata dataset.
18631863
18641864
Parameters
18651865
----------
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.
18711868
convert_dates : dict
18721869
Dictionary mapping columns containing datetime types to stata
18731870
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,
19091906
19101907
.. versionadded:: 0.23.0
19111908
1912-
Returns
1913-
------
1914-
Stata (dta) file or StataWriter.
1915-
19161909
Raises
19171910
------
19181911
NotImplementedError
@@ -1934,22 +1927,12 @@ def to_stata(self, fname, convert_dates=None, write_index=True,
19341927
19351928
Examples
19361929
--------
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.
19391931
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',
19431933
... 'parrot'],
1944-
... 'speed': [350, 18, 361, 15]}).set_index(['date',
1945-
... 'animal'])
1934+
... 'speed': [350, 18, 361, 15]})
19461935
>>> 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()
19531936
"""
19541937
kwargs = {}
19551938
if version not in (114, 117):

0 commit comments

Comments
 (0)