更新了.我没有输入
dict
个数据,而是换成了dataframe
我正在分析一个大约有10,000行和2列的DataFrame.
我的分析标准是基于某些单词是否出现在某个单元格中.
我相信,如果我知道哪些词与价值观最相关,我会更成功……
Foo data to be used as an example:
data = { 'product': ['Dell Notebook I7', 'Dell Notebook I3', 'Logitech mx keys', 'Logitech mx 2'],
'cost': [1000,1200,300,100]}
df_data = pd.DataFrame(data)
product | cost | |
---|---|---|
0 | Dell Notebook I7 | 1000 |
1 | Dell Notebook I3 | 1200 |
2 | Logitech mx keys | 300 |
3 | Logitech mx 2 | 100 |
基本上,栏product
显示了产品的描述.
列cost
中显示的是产品成本.
What I want:
我想创建另一个数据帧,如下所示:
Desired Output:
unique_words | total_cost_for_unique_word | |
---|---|---|
1 | Dell | 2200 |
4 | Logitech | 2200 |
5 | Notebook | 2200 |
2 | I3 | 1200 |
3 | I7 | 1000 |
7 | mx | 400 |
6 | keys | 300 |
0 | 2 | 100 |
- 列
unique_words
,具有出现在列product
中的每个单词的列表. - 列
total_cost_for_unique_word
,其中包含该单词的产品的值之和.
我试着在这里搜索StackOverflow的帖子...此外,我也做了谷歌搜索,但还没有找到解决方案.也许我仍然没有找到答案的知识.
如果这个帖子已经被回复了,请让我知道,我会删除这个帖子.
谢谢大家.