Open MaxGhenis opened 3 years ago
Example given d = mdf.MicroDataFrame(dict(g=["a", "a", "b"], y=[1, 2, 3]), weights=[4, 5, 6]):
d = mdf.MicroDataFrame(dict(g=["a", "a", "b"], y=[1, 2, 3]), weights=[4, 5, 6])
d.groupby("g").sum() works:
d.groupby("g").sum()
y -- 14.0 18.0
d.groupby("g").y.sum() also works:
d.groupby("g").y.sum()
g a 14.0 b 18.0 dtype: float64
d.groupby("g").sum()["y"] works too:
d.groupby("g").sum()["y"]
g a 14.0 b 18.0 Name: y, dtype: float64
d.groupby("g")[["y"]].sum() does not:
d.groupby("g")[["y"]].sum()
| y -- | -- 3 3
d.groupby("g")["y"].sum() also doesn't work:
d.groupby("g")["y"].sum()
g a 3 b 3 Name: y, dtype: int64
d.groupby("g").sum()[["y"]] produces a KeyError (see #192).
d.groupby("g").sum()[["y"]]
KeyError
Need to add a __getitem__ to DataFrameGroupBy:
__getitem__
DataFrameGroupBy
https://github.com/PSLmodels/microdf/blob/0760dfecae5a5b8974d87622644f0df6248e26ce/microdf/generic.py#L416
Example given
d = mdf.MicroDataFrame(dict(g=["a", "a", "b"], y=[1, 2, 3]), weights=[4, 5, 6])
:d.groupby("g").sum()
works:d.groupby("g").y.sum()
also works:d.groupby("g").sum()["y"]
works too:d.groupby("g")[["y"]].sum()
does not:d.groupby("g")["y"].sum()
also doesn't work:d.groupby("g").sum()[["y"]]
produces aKeyError
(see #192).