0

I am trying to replace NAN from a dataframe column which is of float type.

> for i in range(len(tdf)):
>     if tdf['Counterfeit_Weight'][i] =='NaN': # also have tried with np.NaN
>         tdf.loc[i,"Counterfeit_Weight"]=p

I tried np.where, imputer class but nothing is working.

tdf.isnull().sum()
Medicine_ID               0
Counterfeit_Weight     1166
DistArea_ID               0
Active_Since              0  

Plz Help

1

1 Answer 1

1

Following one line should work for you

tdf['Counterfeit_Weight'].fillna(p)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.