Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
There is a second code, but you need to somehow convert the arrays into a dataframe for further use, so I don’t know how to do it (I hope it was clear)
def random_nans(data, n):
data_new = [n]
for i in range(n):
data_new. append(data.loc[np.random.randint(338),:].values)
return data_new
pd.DataFrame(random_nans(data, np.random.randint(90)))
How to convert arrays and lists to DataFrame - described in any pandas manual.
Two dimensional list:
import pandas as pd
import numpy as np
list_a =
columns = ['a','b','c','d','e']
df_a = pd.DataFrame(list_a, columns=columns)
pd.DataFrame(np.random.rand(3, 2), columns=['foo', 'bar'])
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question