I have a Dataframe (image), I want to replace the 0 values in 'LotFrontage' using the dictionary
I want to go through 'LotFrontage' to find 0 Values, then I would like to find the 'Neighborhood' name, and finally, use my dictionary "dic" to find the 'Neighborhood' name and replace the 0 value by the value link the the 'Neighborhood' name
di = {'NWames': 46.0,'Sawyer': 28.0,'NAmes':30.0,'IDOTRR': 62.0,'Crawfor': 82.0,'Edwards': 82.0}
#I would like to have
d= {'Neighborhood':['NWAmes','Sawyer','NAmes','SawyerW','CollgCr','Gilbert','IDOTRR','Crawfor','Edwards'],
'LotFrontage':[46.1,0,30.0,28.5,4,5,82.0,6]}
df = pd.DataFrame(data =d)
df=

Aucun commentaire:
Enregistrer un commentaire