我尝试使用python对银行对账单上的交易进行分组。交易列在CSV文件中。我无法让它使用部分描述而不是整个描述。
我尝试了下面的代码,但它不工作,因为它使用了整个描述。(即AMZN MKTP 09/01 PURCHASE)这是太具体了。我希望它只使用“AMZN”排序。
grouped = test.groupby(['Description'])
for key, item in grouped:
print('Key is: ' + str(key))
print(str(item), '\n\n')
1条答案
按热度按时间r7xajy2e1#
您可以创建包含分组所依据的信息的额外列:
注意我假设description是空格可分的,你只需要第一个单词。