📜  pandas 重新采样按列值分层 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:33.531000             🧑  作者: Mango

代码示例1
# stratified split dataset by column
from sklearn.model_selection import train_test_split
df_sample, df_drop_it = train_test_split(df, train_size =0.2, stratify=df['country'])