ENH: Support Stata variable labels (original) (raw)
xref #13535 (comment)
cc @frehoy
It seems that is is almost implemented here.
See
https://github.com/pydata/pandas/blob/master/pandas/io/stata.py#L2057and
https://github.com/pydata/pandas/blob/master/pandas/io/stata.py#L2134
As you can see, this always passes the default None and so no labels are written.
Mostly needs an external interface and a tiny amount of wiring up. And testing, esp that the labels can be read into Stata.
A possible API
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, variab_labels=labdict)