from sklearn.model_selection import train_test_split
train_df, test_df = train_test_split(adult, test_size=0.2, random_state=42)
train_df.head()| age | workclass | fnlwgt | education | ... | capital.loss | hours.per.week | native.country | income | |
|---|---|---|---|---|---|---|---|---|---|
| 5514 | 26 | Private | 256263 | HS-grad | ... | 0 | 25 | United-States | <=50K |
| 19777 | 24 | Private | 170277 | HS-grad | ... | 0 | 35 | United-States | <=50K |
| 10781 | 36 | Private | 75826 | Bachelors | ... | 0 | 40 | United-States | <=50K |
| 32240 | 22 | State-gov | 24395 | Some-college | ... | 0 | 20 | United-States | <=50K |
| 9876 | 31 | Local-gov | 356689 | Bachelors | ... | 0 | 40 | United-States | <=50K |
5 rows × 15 columns