上传者: 38679178
|
上传时间: 2022-05-07 22:26:56
|
文件大小: 30KB
|
文件类型: PDF
如下所示:
import pandas as pd
content = ['T', 'F'] * 10
data = pd.DataFrame(content, columns=['Y'])
print(data)
Y
0 T
1 F
2 T
3 F
4 T
5 F
6 T
7 F
8 T
9 F
10 T
11 F
12 T
13 F
14 T
15 F
16 T
17 F
18 T
19 F
data.loc[data['Y'] == 'T'] = 1
data.loc[data['Y'] == 'F'] = 0
print(data)
Y
0 1
1 0
2 1
3 0
4 1
5