PolicyEngine / microdf

Analysis tools for working with survey microdata as DataFrames.
http://pslmodels.github.io/microdf
MIT License
12 stars 10 forks source link

MicroDataFrame[[cols]] produces KeyError #192

Closed MaxGhenis closed 3 years ago

MaxGhenis commented 3 years ago

This works in pandas and should produce a MicroDataFrame with only the column x:

d = mdf.MicroDataFrame(dict(x=[1, 2], y=[3, 4]), weights=[5, 6])
d[["x"]]

But it errors out instead:

KeyError: "None of [Index(['x'], dtype='object')] are in the [index]"
MaxGhenis commented 3 years ago

This should just be self.weights:

https://github.com/PSLmodels/microdf/blob/0760dfecae5a5b8974d87622644f0df6248e26ce/microdf/generic.py#L596