我有一个熊猫数据框
这是通过在列上应用.value_counts()
来实现的,正如您所看到的,开发人员与其他人的答案结合在一起时是重复的,从这个数据框架中,我想创建一个可能的日志列表,以计算稍后重复的每个日志的数量
我尝试了下面的代码以首先找到唯一的值
unqlist=list(df_new['DevType'].unique())
通过使用“unqlist”,我尝试使用下面的代码来分隔不同的单词
possiblewords=[]
for word in unqlist:
print(word.split(','))
possiblewords.append(word)
它不起作用了
以下是一个例子:
list(set(''.join(filter(lambda x: isinstance(x, str), devtype_list)).split(',')))
您可以使用Pandas^{} 在逗号和分号上拆分,将结果放入numpy数组中。然后,使用^{} 获得从2D数组展平到1D数组后的唯一字,如下所示:
结果:
您可以使用
,
和;
作为分隔符拆分列表,以分隔唯一的单词结果:
相关问题 更多 >
编程相关推荐