I have a data frame (data_train) with NaN values, A sample is given below:
republican n y republican n NaN democrat NaN n democrat n y
I want to replace all the NaN with some random values like .
republican n y republican n rnd2 democrat rnd1 n democrat n y
How do I do it.
I tried the following, but had no luck:
df_rand = pd.DataFrame(np.random.randn(data_train.shape,data_train.shape)) data_train[pd.isnull(data_train)] = dfrand[pd.isnull(data_train)]
when I do the above with a dataframe with random numerical data the above script works fine.