Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 df,我想在其中执行一个虚拟函数,但我想总结帐户数量而不是每个创建的虚拟对象的计数。
现在,我正在使用:dummies=second.set_index(['month_end_dt'])['product'].str.get_dummies().sum(level=0).reset_index()
dummies=second.set_index(['month_end_dt'])['product'].str.get_dummies().sum(level=0).reset_index()
但是,它会返回给定月份每种产品的计数(见下图)。相反,我希望获得给定月份和给定虚拟变量的帐户总和(即 2、3、5)。我该怎么做?