Error in f500 dataframe

Hello everyone, I am working on Exploring Data with pandas: Fundamentals screen 10: Using Boolean Arrays to Assign Values.

Here are my codes:
import numpy as np
f500 = pd.read_csv( “f500.csv”, index_col = 0) = None
prev_rank_before = f500[“previous_rank”].value_counts(dropna=False).head()
f500.loc[f500[‘previous_rank’] == 0, ‘previous_rank’] = np.nan
prev_rank_after = f500[‘previous_rank’].value_counts(dropna = False).head()

after running the code and submitting the result, the variable prev_rank_after is ok but the variable f500 kept showing error. But I did a visual comparison between the actual and expected value, for the light of my life I just couldn’t find what is problem. The only difference is the dtype of column ‘previous_rank’ changed from integer to float. But does this matter?

your help will be really appreciated.

Hi @sidney.q, welcome to the community!
Could you try the code without the line where you read in the csv? I’m thinking you are overwriting the f500 that’s already loaded for that screen and that will make it different than the answer checker. If you still get the same error, you may want to reset the code for that screen and try again.

1 Like

ah, that worked. thank you!

1 Like