lundi 22 mars 2021

replace NaN with random values from a range

I am using this code to replace NaN with random values from a range

import numpy as np
def processNan (x):
     return np.random.choice([1.0, 2.0])
assure['codeTypePieceIdentite'] = assure['codeTypePieceIdentite'].apply(lambda x: processNan(x) if x is nan else x)

its not working for some reason nothing changes

result




Aucun commentaire:

Enregistrer un commentaire