我有一个带有6个不同变量的“部门”列的数据框。
但是,当我创建新的df时,请使用:
indicator = dept.groupby('Department')[['Assignment Status']].count()
df包含“ R&D操作”的两个条目:
Department Assignment Status
Business Services 17616
Operations 112958
Quality Assurance 28070
Quality Control 32860
R&D Operations 63206
R&D Operations 275
这一定是与原始df格式有所不同的类型。如何合并“部门”列中的这两个条目。
非常感谢
我认为此问题一定是由于@CypherX和@Dani建议的值中存在空格
# To remove the white spaces from both ends (left and right)
dept.Department = dept.Department.str.strip()
# Then perform the groupby operation
indicator = dept.groupby('Department')[['Assignment Status']].count()
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句