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)
f500.index.name = 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.