1
在下面一行中,INDATUMA
的dtype是int64。爲什麼生成的系列具有dtype對象?python熊貓爲什麼會在對象中搜索結果
all_treatments['year'] = (all_treatments['INDATUMA']/10000).round
我覺得pandas.Series.round
只是numpy.around
投給每個元素。
在下面一行中,INDATUMA
的dtype是int64。爲什麼生成的系列具有dtype對象?python熊貓爲什麼會在對象中搜索結果
all_treatments['year'] = (all_treatments['INDATUMA']/10000).round
我覺得pandas.Series.round
只是numpy.around
投給每個元素。
我想你忘記了()
,所以round
回報method Series.round
:
all_treatments['year'] = (all_treatments['INDATUMA']/10000).round()
樣品:
print all_treatments
INDATUMA A C D
0 17030 5 a 2
1 72020 9 a b
2 28279 10 c d
3 32037 2 c c
all_treatments['year'] = (all_treatments['INDATUMA']/10000).round
print all_treatments
INDATUMA A C D year
0 17030 5 a 2 <bound method Series.round of 0 1.7030\n1 ...
1 72020 9 a b <bound method Series.round of 0 1.7030\n1 ...
2 28279 10 c d <bound method Series.round of 0 1.7030\n1 ...
3 32037 2 c c <bound method Series.round of 0 1.7030\n1 ...
all_treatments['year'] = (all_treatments['INDATUMA']/10000).round()
print all_treatments
INDATUMA A C D year
0 17030 5 a 2 2
1 72020 9 a b 7
2 28279 10 c d 3
3 32037 2 c c 3