2021年3月22日星期一

Pandas how to interpolate or fillna missing price values for car makes?

I'm using this automobile dataset and I have doubt on which method to use to fill the missing price values. Is that even something that is worth worrying about since price is subjective?

Is it better to just drop these rows?

I was thinking I could calculate the mean price for each of the specific makes and fillna with it - would that give me a close enough interpolation of the missing values?

distinctNullMakes = automobile.loc[automobile.Price.isna() , 'Make'].unique()    for make in distinctNullMakes:      mask = automobile.Make == make       mean = round(automobile.Price[mask].mean())      automobile[mask] = automobile[mask].fillna(mean)  

Also this piece of code doesn't look very elegant, is there a better way (obviously I'm a noob)?

https://stackoverflow.com/questions/66757087/pandas-how-to-interpolate-or-fillna-missing-price-values-for-car-makes March 23, 2021 at 11:58AM

没有评论:

发表评论