Skip to content

ENH: Support Stata variable labels #13536

Closed
@TomAugspurger

Description

@TomAugspurger

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#L2057

and

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions