How to sample pandas DataFrame with replacement?
dataframe, pandas, python
Solution
use `iloc[]`:
df.iloc[np.random.randint(0, len(df), size=k)]
Problem
I have a DataFrame, size N. I need to sample it with S samples, with replacement where N < S. ``` def sampleDF(df, K): return df.ix[np.random.randint(0, len(df), size=k)] ``` I return a new DF but it seems everything is filled with NaN. Am not sure what's going on!