2021年5月5日星期三

How to deal with misssing values in Pandas

I´d like to know when we have a dataset with missing values, what´s the best way to treat them? Remove them directly or replace with zeros?

Suppose i have these dates:

id name price product_group
1 nd 14.35 care
2 nd 10.02 makeup
3 nd 5.40 nd
4 nd 7.68 nd

I need to analyse the dates in the column 'product group' and tried to remove the values 'nd' using this code but it doesnt work.

    order['product_group'] = order['product_group'].replace('nd', np.nan)      order['product_group'] = order['product_group'].dropna(how='any')  
https://stackoverflow.com/questions/67409990/how-to-deal-with-misssing-values-in-pandas May 06, 2021 at 07:26AM

没有评论:

发表评论