[FIXED] Introduction to Pandas: wrong answer in quiz

link: https://www.codecademy.com/paths/analyze-data-with-python/tracks/ida-4-data-manipulation-pandas/modules/ida-4-1-introduction-to-pandas/quizzes/pandas-introduction-quiz-ii

This question has wrong answer. The answer’s variable name doesn’t follow variable rules so that it will throw SyntaxError. So the answer’s variable name must concatenate with ‘_’, not ‘-’. Or second’s answer could be correct answer if the DataFrame is assign as ‘column’. Plz check it out :slight_smile:

1 Like

Yes. I believe you are correct. For the ‘Correct’ answer to actually be correct is should read:

office-supply-store['remaining-inventory'] = office-supply-store['initial-inventory'] - office-supply-store['number-sold']

No clue why they decided to use hyphens in all of the names here. Bizarre!
Would either @patrickd314, @thepitycoder or @chuckwondo care to weigh in before I report this as a bug?

3 Likes

I think your proposed correction is correct… The column names, e.g. number-sold aren’t valid identifiers so you would (I think) need to use the df.[colname] form…

3 Likes
office_supply_store['remaining-inventory'] = office_supply_store['initial-inventory'] - office_supply_store['number-sold']

Thanks! I guess it’s what you mean :slight_smile:
I hope to codecademy will fix it soon

Yes it is. As you mentioned, df[columnName] form is correct :slight_smile:

Actually the data frame itself having hyphens in the name seems to work, but the hyphens in the column names require using the df['column-name'] syntax to reference them. Again, I don’t know why they would have used hyphens. It likely is a typo.

2 Likes

I see. I hope they fix it soon. Thanks! :rofl:

1 Like

I submitted a bug report directly to the Codecademy Team. We’ll see what happens.

1 Like

Thanks again, @eunsukimme, for reporting this bug. It has been fixed!

1 Like

This topic was automatically closed 18 hours after the last reply. New replies are no longer allowed.