Issue in Exploring Data with pandas

Hi All

I am getting weird issue while getting output.

can you please advise the issue -

Requirement -
select all rows from f500 that have a null value for the previous_rank column. Select only the company , rank , and previous_rank columns. Assign the result to null_previous_rank .

Actual Output :

Expected output :

Hello @san.sap201,

I had the same error. It was due to omission of 2. Reading CSV files with Pandas, where 0 are turned into NaN in previous_rank column:

f500.loc[f500["previous_rank"] == 0, "previous_rank"] = np.nan

Omitting this step leads to:

  1. 0 instead of NaN
  2. f500["previous_rank"].isnull() returns nothing
  3. f500[f500["previous_rank"].isnull()] returns an empty DataFrame

Is this also the case in your problem?

Thank You. converting the ‘0’ to NaN solved the problem.
f500.loc[f500[“previous_rank”] == 0, “previous_rank”] = np.nan

1 Like