Why are my values of string column of dataframe getting converted to NaN when I sort my dataframe according to SaleDate

  Kiến thức lập trình

My original data has a UsageBand column which has string values of low, medium and high(along with a few missing entries). But when I apply sort_values function to my data and sort it according to “saledate” column, all the string values of UsageBand column(along with other string columns) get converted to NaN. Why is this happening?

this is the original data with string values in UsageBand column

this is the code snippet for sorting –

df.sort_values(by=[“saledate”],inplace=True,ascending= True)

this is data after sorting. NOTE the values in UsageBand column getting converted to NaN

I expected the values in UsageBand column to remain of string type even after applying sorting.

LEAVE A COMMENT