Skip to content

Commit 2016051

Browse files
committed
Modified to_stata docstring
1 parent fc16a87 commit 2016051

File tree

2 files changed

+28
-37
lines changed

2 files changed

+28
-37
lines changed

pandas/core/frame.py

+19-9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
# pylint: disable=E1101
23
# pylint: disable=W0212,W0703,W0622
34
"""
@@ -1846,12 +1847,15 @@ def to_stata(self, fname, convert_dates=None, write_index=True,
18461847
data_label=None, variable_labels=None, version=114,
18471848
convert_strl=None):
18481849
"""
1849-
Export Stata binary dta files.
1850+
Converting data frame object to Stata dta format.
1851+
1852+
Writes the Dataframe to a Stata dataset file.
1853+
"dta" files contain a Stata dataset.
18501854
18511855
Parameters
18521856
----------
18531857
fname : path (string), buffer or path object
1854-
string, path object (pathlib.Path or py._path.local.LocalPath) or
1858+
String, path object (pathlib.Path or py._path.local.LocalPath) or
18551859
object implementing a binary write() functions. If using a buffer
18561860
then the buffer will not be automatically closed after the file
18571861
data has been written.
@@ -1911,26 +1915,32 @@ def to_stata(self, fname, convert_dates=None, write_index=True,
19111915
19121916
See Also
19131917
--------
1914-
pandas.read_stata : Import Stata data files
1915-
pandas.io.stata.StataWriter : low-level writer for Stata data files
1916-
pandas.io.stata.StataWriter117 : low-level writer for version 117 files
1918+
pandas.read_stata : Import Stata data files.
1919+
pandas.io.stata.StataWriter : Writer for Stata data files.
1920+
pandas.io.stata.StataWriter117 : Writer for version 117 files.
19171921
19181922
Examples
19191923
--------
1920-
>>> data.to_stata('./data_file.dta')
1924+
1925+
>>> df = pd.DataFrame({'col1': [1, 2, 3], 'col2': [4, 5, 6]})
1926+
>>> df.to_stata('./data_file.dta')
19211927
19221928
Or with dates
19231929
1924-
>>> data.to_stata('./date_data_file.dta', {2 : 'tw'})
1930+
>>> dates_1 = pd.to_datetime(["2016-05-06","2017-05-07", "2018-05-10"])
1931+
>>> dates_2 = pd.to_datetime(["2016-11-06","2017-11-07", "2018-11-10"])
1932+
>>> df_dates = pd.DataFrame({'date1': dates_1, 'date2': dates_2})
1933+
>>> df_dates.to_stata('./date_data_file.dta', {2 : 'tw'})
19251934
19261935
Alternatively you can create an instance of the StataWriter class
19271936
1928-
>>> writer = StataWriter('./data_file.dta', data)
1937+
>>> StataWriter = pd.io.stata.StataWriter
1938+
>>> writer = StataWriter('./data_file.dta', df)
19291939
>>> writer.write_file()
19301940
19311941
With dates:
19321942
1933-
>>> writer = StataWriter('./date_data_file.dta', data, {2 : 'tw'})
1943+
>>> writer = StataWriter('./date_data_file.dta', df_dates, {2 : 'tw'})
19341944
>>> writer.write_file()
19351945
"""
19361946
kwargs = {}

pandas/core/strings.py

+9-28
Original file line numberDiff line numberDiff line change
@@ -855,13 +855,9 @@ def _str_extract_frame(arr, pat, flags=0):
855855

856856

857857
def str_extract(arr, pat, flags=0, expand=True):
858-
<<<<<<< HEAD
859858
"""
860-
=======
861-
r"""
862859
Extract capture groups in the regex `pat` as columns in a DataFrame.
863860
864-
>>>>>>> 21e8522102c334acb79dd4a7b3f7a914af535a8e
865861
For each subject string in the Series, extract groups from the
866862
first match of regular expression `pat`.
867863
@@ -1431,11 +1427,7 @@ def str_split(arr, pat=None, n=None):
14311427

14321428

14331429
def str_rsplit(arr, pat=None, n=None):
1434-
<<<<<<< HEAD
1435-
1436-
=======
14371430

1438-
>>>>>>> 21e8522102c334acb79dd4a7b3f7a914af535a8e
14391431
if n is None or n == 0:
14401432
n = -1
14411433
f = lambda x: x.rsplit(pat, n)
@@ -2350,11 +2342,9 @@ def cat(self, others=None, sep=None, na_rep=None, join=None):
23502342
Split strings around given separator/delimiter.
23512343
23522344
Splits the string in the Series/Index from the %(side)s,
2353-
<<<<<<< HEAD
23542345
at the specified delimiter string.Equivalent to :meth:`str.%(method)s`.
2355-
=======
23562346
at the specified delimiter string. Equivalent to :meth:`str.%(method)s`.
2357-
>>>>>>> 21e8522102c334acb79dd4a7b3f7a914af535a8e
2347+
23582348
23592349
Parameters
23602350
----------
@@ -2375,8 +2365,7 @@ def cat(self, others=None, sep=None, na_rep=None, join=None):
23752365
Series, Index, DataFrame or MultiIndex
23762366
Type matches caller unless ``expand=True`` (see Notes).
23772367
2378-
<<<<<<< HEAD
2379-
=======
2368+
23802369
See Also
23812370
--------
23822371
Series.str.split : Split strings around given separator/delimiter.
@@ -2387,7 +2376,7 @@ def cat(self, others=None, sep=None, na_rep=None, join=None):
23872376
str.split : Standard library version for split.
23882377
str.rsplit : Standard library version for rsplit.
23892378
2390-
>>>>>>> 21e8522102c334acb79dd4a7b3f7a914af535a8e
2379+
23912380
Notes
23922381
-----
23932382
The handling of the `n` keyword depends on the number of found splits:
@@ -2400,7 +2389,7 @@ def cat(self, others=None, sep=None, na_rep=None, join=None):
24002389
If using ``expand=True``, Series and Index callers return DataFrame and
24012390
MultiIndex objects, respectively.
24022391
2403-
<<<<<<< HEAD
2392+
24042393
See Also
24052394
--------
24062395
%(also)s
@@ -2468,14 +2457,14 @@ def cat(self, others=None, sep=None, na_rep=None, join=None):
24682457
0 1 2 3
24692458
0 this is good text
24702459
1 but this is even better
2471-
2 NaN NaN NaN NaN
2460+
2 NaN NaN NaN NaN
24722461
24732462
>>> s.str.rsplit(n=3, expand=True)
24742463
0 1 2 3
24752464
0 this is good text
24762465
1 but this is even better
24772466
2 NaN NaN NaN NaN
2478-
=======
2467+
24792468
Examples
24802469
--------
24812470
>>> s = pd.Series(["this is a regular sentence",
@@ -2544,31 +2533,23 @@ def cat(self, others=None, sep=None, na_rep=None, join=None):
25442533
0 this is a regular sentence None
25452534
1 https://docs.python.org/3/tutorial index.html
25462535
2 NaN NaN
2547-
>>>>>>> 21e8522102c334acb79dd4a7b3f7a914af535a8e
2536+
25482537
""")
25492538

25502539
@Appender(_shared_docs['str_split'] % {
25512540
'side': 'beginning',
2552-
<<<<<<< HEAD
25532541
'method': 'split',
2554-
'also': 'rsplit : Splits string at the last occurrence of delimiter'
2555-
})
2556-
=======
2542+
'also': 'rsplit : Splits string at the last occurrence of delimiter',
25572543
'method': 'split'})
2558-
>>>>>>> 21e8522102c334acb79dd4a7b3f7a914af535a8e
25592544
def split(self, pat=None, n=-1, expand=False):
25602545
result = str_split(self._parent, pat, n=n)
25612546
return self._wrap_result(result, expand=expand)
25622547

25632548
@Appender(_shared_docs['str_split'] % {
25642549
'side': 'end',
2565-
<<<<<<< HEAD
25662550
'method': 'rsplit',
2567-
'also': 'split : Splits string at the first occurrence of delimiter'
2568-
})
2569-
=======
2551+
'also': 'split : Splits string at the first occurrence of delimiter',
25702552
'method': 'rsplit'})
2571-
>>>>>>> 21e8522102c334acb79dd4a7b3f7a914af535a8e
25722553
def rsplit(self, pat=None, n=-1, expand=False):
25732554
result = str_rsplit(self._parent, pat, n=n)
25742555
return self._wrap_result(result, expand=expand)

0 commit comments

Comments
 (0)