pandas库的常用操作,参考书籍《Pandas Cookbook》,内容干货,推荐下载!movie get_dtype_counts# output the number of columns with each specific data type:
movie. select_dtypes(include['int ]).head(# select only integer columns
movie. filter(1ike=' facebook').head()#1ike参数表示包含此
如下所示:
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']