w ='''1 181 80 M 中
2 179 50 W 瘦
3 155 70 M 胖
4 168 50 M 中
5 160 40 W 瘦'''
w = pd.DataFrame([i.split('\t')for i in w.split('\n')])
train = w[[1,4,3]]# 训练集
train.columns =['身高','胖瘦','性别']
train # 训练数据
C:\Users\Administrator\AppData\Local\Temp\ipykernel_10428\1286987125.py:1: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
train['身高'] = train['身高'].astype('int')