【发布时间】:2021-08-17 22:45:06
【问题描述】:
我有一个示例数据:
date product campaign_type total_monthly_sale
2019-01-01. Dell [call, email, call]. 5
2019-01-01. Apple [fax, fax, visit, visit] 4
2019-02-01. Dell [call, fax, call] 6
2019-02-01. Apple [email, email, visit] 7
我想创建一个名为 'campaign_dict' 的新列,它给出了来自 campaign_type 列的值的计数。
示例输出如下:
date product campaign_type total_monthly_sale. campaign_dict
2019-01-01. Dell [call, email, call]. 5. {'call':2,'email':1}
2019-01-01. Apple. [fax, fax, visit, visit]. 4. {'fax':2,'visit':2}
2019-02-01. Dell. [call, fax, call] 6. {'call':2,'fax':1}
2019-02-01. Apple. [email, email, visit]. 7 {'email':2,'visit':1}
【问题讨论】:
-
是
campaign_type列表还是字符串?因为.让我觉得它是字符串 -
字符串列表
-
为什么我们会在输出中看到一个点?
-
对不起,不是点..这是一个错误
标签: python pandas dataframe numpy data-science