我刚刚开始学习熊猫,这是一个非常基本的问题。相信我,我一直在寻找答案,但找不到。在
你能运行这个python代码吗?在
import pandas as pd
df = pd.DataFrame({'A':[1,0], 'B':[2,4], 'C':[4,4], 'D':[1,4],'count__4s_abc':[1,2],'sum__abc':[7,8]})
df
如何创建“count_u4s_uabc”列,在该列中,我要计算数字4在A-C列中出现的次数?(忽略D列。)
如何创建“sum_uuabc”列,在该列中我只想将A-C列中的金额相加?(忽略D列。)
非常感谢您的帮助!在
一个附加选项:
^{} method can (but not always) be faster compared to regular Pandas arithmetic
使用
drop
或者显式地选择3列。在
^{pr2}$或者使用
iloc
获得前3列。在都给
相关问题 更多 >
编程相关推荐