PolicyEngine / microdf

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

Deprecate MicroDataFrame.set_weight_col #208

Open MaxGhenis opened 3 years ago

MaxGhenis commented 3 years ago

MicroDataFrame.set_weights already works passing in a string so set_weight_col seems redundant:

In [2]: d = mdf.MicroDataFrame({"x": [1, 2]}, weights=[3, 4])

In [3]: d.set_weights("x")

In [4]: d.weights
Out[4]: 
0    1.0
1    2.0
Name: x, dtype: float64

In [5]: d.set_weights([6, 7])

In [6]: d.weights
Out[6]: 
0    6.0
1    7.0
dtype: float64
MaxGhenis commented 3 years ago

Actually this doesn't work:

In [2]: d = mdf.MicroDataFrame({"x": [1, 2]}, weights=[3, 4])

In [3]: d.x.sum()
Out[3]: 11.0

In [4]: d.set_weights("x")

In [5]: d.x.sum()
Out[5]: 11.0

Still seems better to fix this and make set_weights work with both a column name and values than to have two.