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萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章