Closed erineidschun closed 5 years ago
Since you select out the year 2000 (df.YEAR == 2000
), you don't then need to group by year. You can, and that's why it still runs ok at that point. The problem arises when you try to use weights_2000
as the weights. When you group by year, it puts YEAR
in as a level in the MultiIndex. Just don't group by year, and that should help!
Actually I had the same bug, but I think it is because you should look at the "YEAR" variable more closely. "YEAR" is actually a date... not a 4 digit year which tripped me up. I think we should set df.YEAR == '2000-01-01' instead of 2000.
Hope this makes sense and fixes errors
My code for #24 does not seem to be working:
I suspect it has to do with the bolded part.
.groupby(by=['YEAR','age_binned', 'educ_binned'])
In that line, I've also tried including only 'age_binned' and 'educ_binned', and when doing that, or doing the code shown above, I get an error: Axis must be specified when shapes of a and weights differ. This points to the .apply(lambda x: np.average... line.
Additionally, what exactly are we supposed to compute for the employment variable in #11? I used in_labor_force and used np.average for this, but not sure if this is what you wanted.