Python Pandas数据框列在拆分数据部分上未正确更新

时间:2018-11-21 02:33:35

标签: python-3.x pandas split

我有一个Python函数来拆分数据,其格式为小数:4 / 5、1 / 1、1,2等。此函数通过数据帧进行迭代。 split()函数。 print()语句分别显示对变量s [0]和s [1]的正确分割。问题在于df_ff_reviews ['NumHelpfulVotes'] = s [0]和df_ff_reviews ['NumVotes'] = s [1]数据帧列未分别使用s [0],s [1]的分割值进行更新。当我查看数据帧(头)时,我看到列NumHelpfulVotes和NumVotes的所有行都设置为零。切勿在迭代循环内匹配s [0]和s [1]拆分值。

Ata135,Aru2,Aba301,A29,0.055525,0.025,0.1,0.082825,0.075,0.125
Adc,Aru7,Ama301,Agr84,0.002075,0,0.025,0.240075,0.2,0.

1 个答案:

答案 0 :(得分:2)

str.split的{​​{1}}一样

expand