jmbejara / comp-econ-sp18

Main Course Repository for Computational Methods in Economics (Econ 21410, Spring 2018)
16 stars 23 forks source link

HW4 some numbers slightly off compared to sample output #35

Closed vuphan95 closed 6 years ago

vuphan95 commented 6 years ago

screenshot 89 As shown in the screenshot, the numbers I got are slightly off compared to the sample output. What confuses me is the fact that my median wage column is correct but the other two columns are not. I would appreciate some hint to help me look for where and what I did wrong. Thank you very much!

jmbejara commented 6 years ago

Interesting. It's strange to me that you would be getting the same answers on the median but not on the mean. I'm using np.average. I get the same answer when I use weightedstats.numpy_weighted_mean. Immediately after I run the code to compute these series, this is what my instance of df looks like:

image

tyler-patterson commented 6 years ago

I had this exact same issue and it turned out that this happens if you drop NA values AFTER dropping extraneous columns in Q6. If you drop NA values BEFORE getting rid of the columns, you should get the numbers that show up in the sample output.

The question seems to be asking you to drop columns first, leading to the "wrong" values, so rewording the question might make sense.

jmbejara commented 6 years ago

I've updated the HW (see 0fa49a59b7718e1f2308134b87630b7f82355cab) to add this clarification. Thanks for solving this!

wilson97 commented 6 years ago

@vuphan95 did the fix work for you? I have the same issue but reordering the NA drop doesn't help for me.

vuphan95 commented 6 years ago

@wilson97 I went from having many numbers off to having only one or two values different from the sample output.