Document pandas.DataFrame.to_stata data_label · Issue #13535 · pandas-dev/pandas (original) (raw)

I work with Pandas and Stata and found the DataFrame.to_stata() method very valuable. I would like to be able to assign variable labels in my .dta files but the data_label parameter of the DataFrame.to_stata() method is not documented so I do not know in which format to supply my variable labels.

I tried a dictionary of the form {'df column name' : 'wanted label'} but that returns

TypeError: unhashable type: 'slice'

Here is the page in the documentation I am referring to: http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.to_stata.html#pandas.DataFrame.to_stata

If it could be updated to provide a working example of data_label I would be eternally grateful. This is my first issue on github, hope I specified it correctly, feel free to point out if I messed up the format somehow.

Thanks!

Code Sample, a copy-pastable example if possible

import pandas as pd
d = {'one' : [1., 2., 3., 4.]}
df = pd.DataFrame(d)
labdict = {'one': 'foo'}
df.to_stata('test.dta', write_index=False, data_label=labdict)

Expected Output

output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.5.1.final.0
python-bits: 64
OS: Darwin
OS-release: 15.5.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: None

pandas: 0.17.1
nose: 1.3.7
pip: 8.1.1
setuptools: 19.6.2
Cython: 0.23.4
numpy: 1.10.4
scipy: 0.17.0
statsmodels: 0.6.1
IPython: 4.0.3
sphinx: 1.3.5
patsy: 0.4.0
dateutil: 2.4.2
pytz: 2015.7
blosc: None
bottleneck: 1.0.0
tables: 3.2.2
numexpr: 2.4.6
matplotlib: 1.5.1
openpyxl: 2.3.2
xlrd: 0.9.4
xlwt: 1.0.0
xlsxwriter: 0.8.4
lxml: 3.5.0
bs4: 4.4.1
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.11
pymysql: None
psycopg2: None
Jinja2: 2.8