Repository: pandas-dev/pandas

Issue:
Wrong parameter name in to_stata() method
In the [API documentation for `df.to_stata()`](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.to_stata.html), a parameter `dataset_label` is listed to give the Stata file a label, however the Pandas API [actually uses the parameter `data_label`](https://github.com/pandas-dev/pandas/blob/master/pandas/core/frame.py#L1591).
From `core/frame.py`:
> ```python
>     def to_stata(self, fname, convert_dates=None, write_index=True,
>                 encoding="latin-1", byteorder=None, time_stamp=None,
>                 data_label=None, variable_labels=None):
> ```

Thus using `dataset_label` doesn't work, but `data_label` does.
```python
>>> import pandas as pd
>>> df = pd.DataFrame({'col1': [1, 2], 'col2': [3, 4]})
>>> df.to_stata('test.dta', dataset_label='data label')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: to_stata() got an unexpected keyword argument 'dataset_label'
>>> df.to_stata('test.dta', data_label='data label')
```

I'll submit a PR shortly changing that docstring.

#### Output of ``pd.show_versions()``

<details>

INSTALLED VERSIONS
------------------
commit: None
python: 3.6.4.final.0
python-bits: 64
OS: Linux
OS-release: 4.13.0-32-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.22.0
pytest: 3.3.0
pip: 9.0.1
setuptools: 38.5.1
Cython: 0.27.3
numpy: 1.14.0
scipy: 1.0.0
pyarrow: 0.8.0
xarray: None
IPython: 6.2.1
sphinx: 1.6.3
patsy: 0.4.1
dateutil: 2.6.1
pytz: 2017.3
blosc: None
bottleneck: 1.2.1
tables: 3.4.2
numexpr: 2.6.4
feather: 0.4.0
matplotlib: 2.1.1
openpyxl: 2.4.9
xlrd: 1.1.0
xlwt: 1.3.0
xlsxwriter: 1.0.2
lxml: 4.1.1
bs4: 4.6.0
html5lib: 1.0.1
sqlalchemy: 1.1.13
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

</details>



Discussion:

Resolving patch:
diff --git a/pandas/core/frame.py b/pandas/core/frame.py
--- a/pandas/core/frame.py
+++ b/pandas/core/frame.py
@@ -1612,7 +1612,7 @@ def to_stata(self, fname, convert_dates=None, write_index=True,
         time_stamp : datetime
             A datetime to use as file creation date.  Default is the current
             time.
-        dataset_label : str
+        data_label : str
             A label for the data set.  Must be 80 characters or smaller.
         variable_labels : dict
             Dictionary containing columns as keys and variable labels as
@@ -1635,10 +1635,18 @@ def to_stata(self, fname, convert_dates=None, write_index=True,
 
         Examples
         --------
+        >>> data.to_stata('./data_file.dta')
+
+        Or with dates
+
+        >>> data.to_stata('./date_data_file.dta', {2 : 'tw'})
+
+        Alternatively you can create an instance of the StataWriter class
+
         >>> writer = StataWriter('./data_file.dta', data)
         >>> writer.write_file()
 
-        Or with dates
+        With dates:
 
         >>> writer = StataWriter('./date_data_file.dta', data, {2 : 'tw'})
         >>> writer.write_file()


Test patch: