Pandas random sample with remove

前端 未结 2 1276
忘掉有多难
忘掉有多难 2021-02-04 08:31

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

2条回答
  •  囚心锁ツ
    2021-02-04 08:51

    pandas random sample :

    train=df.sample(frac=0.8,random_state=200)
    test=df.drop(train.index)
    

提交回复
热议问题