如題
這是我的data frame
http://i.imgur.com/USqiil5.jpg
我想要把Death year欄位資料為nan的變成0其他都變成1
import pandas as pd
mydata_csv = pd.read_csv('D:\Python\character-deaths.csv',sep = ',',encoding = 'utf-8')
mydata_csv
del mydata_csv['Book of Death']
del mydata_csv['Death Chapter']
if mydata_csv['Death Year'] == None:
mydata_csv['Death Year'] = 0
else:
mydata_csv['Death Year'] = 1
這個是我的程式碼
到if那裡就錯誤了QQ