Closed graceslu closed 5 years ago
Hi @graceslu . The groupby
method includes a keyword argument called level
that will allow you to group by levels in a MultiIndex. This should allow you to group by your index. See the documentation here: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.groupby.html
However, you should be able to complete this HW without using groupby
. I'm using a "for-loop" and the linearmodels
module. The expression to run the fixed effects regression is this:
linearmodels.PanelOLS.from_formula('y ~ k + l + EntityEffects', data=data)
For Q8, I can't figure out how to group the dataframe by firm since 'firm' is an index name, not a column in the dataframe. I added a new column 'firm' to the dataframe that matches the firm for each data point. This was enough to run a fixed effects model, but I'm wondering if there is a much better way to approach this?