使用Pandas将读取到的csv文件列表中的True和False修改为1和0,但是只能赋值给字符串类型的‘1’和‘0’,最后使用的话还需要转换类型。
# encoding:utf-8
import pandas as pd
df = pd.read_csv('./t_login.csv')
# print df
# print df.dtypes
print df['is_scan']
df.at[df['is_scan'] == 1, 'is_scan'] = '1'
df.at[df['is_scan'] == 0, 'is_scan'] = '0'
print df.head()
# link=[]
# for line in df.values:
# link.append(str(line[0]))
# print link
s=df.iloc[2]
# s=s.replace(1,'one')
print s.replace(1,'one')