python使用pandas进行数据转换

import pandas as pd
text11 = pd.read_table('G:/paper/yeast4/test14.txt',sep=',',header = None)
text11[8] = text11[8].str.replace('positive','1')
text11[8] = text11[8].str.replace('negative','-1')
#print text11
#text11 = text11.replace('negative',-1)
#text11 = text11.replace('positive',1)                    
text11.to_csv('G:/paper/yeast4/test14.csv')
发布了39 篇原创文章 · 获赞 40 · 访问量 8万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章