I\'m aware of DataFrame.sample(), but how can I do this and also remove the sample from the dataset? (Note: AFAIK this has nothing to do with sampling with repl
DataFrame.sample()
If your index is unique
df = df.drop(df_subset.index)
example
df = pd.DataFrame(np.arange(10).reshape(-1, 2))
sample
df_subset = df.sample(2) df_subset
drop
df.drop(df_subset.index)
pandas random sample :
train=df.sample(frac=0.8,random_state=200) test=df.drop(train.index)