lundi 24 avril 2023

pandas fill empty cells from a column with random range number or index number [duplicate]

read a excel file and i take the dataframe. The empty cells from excel now appears with NaN. For a column i try fill each one NaN cells with a random number with range (10000,100000)

import random
all_df.loc[all_df["name"].isnull(),'name'] = random.randrange(10000,100000)

but with this fill NaN cells from this column with one random number all NaN cells

another column with NaN cells i try fill them with index number of row

all_df.loc[all_df["name"].isnull(),'name'] = all_df["name"].index.values

can anyone help me with this problem?




Aucun commentaire:

Enregistrer un commentaire