vendredi 24 juin 2022

fillna the missing values from another column

enter image description here

LotFrontage column have relationship with LotArea the values of LotFrontage is between 0.005% - 0.01% of the LotArea.

I am trying to get the random values between 0.005% - 0.01% of LotArea where LotFrontage is missing.

Example: In the pic at 1019 index values is missing for LotFrontage. I want to fill it with LotArea value 8978 * 0.005 to 8978 * 0.01

Code(to solve this issue):

np.where(df_train[df_train["LotFrontage"].isnull()], np.random.rand(df_train['LotArea']*0.005, df_train["LotArea"]*0.01),df_train["LotFrontage"])
Error:
TypeError                                 Traceback (most recent call last)
<ipython-input-46-49a940deebcd> in <module>()
----> 1 np.random.rand(df_train['LotArea'] *0.005,df_train["LotArea"] * 0.01)
mtrand.pyx in numpy.random.mtrand.RandomState.rand()
mtrand.pyx in numpy.random.mtrand.RandomState.random_sample()
_common.pyx in numpy.random._common.double_fill()
TypeError: 'Series' object cannot be interpreted as an integer



Aucun commentaire:

Enregistrer un commentaire