首页 > 其他分享 >列表字符串去重

列表字符串去重

时间:2022-10-27 16:13:01浏览次数:41  
标签:set df list1 列表 pd 字符串 list2 append

import pandas as pd

dfs = pd.read_excel("工作表.xlsx", sheet_name=None, usecols=['列名'])
df = pd.concat(dfs)

list1 = []
for i in df["列名"]:
    list1.append(eval(i))

list2 = []
for i in list1:
    for j in i:
        list2.append(j)

set_data = set(list2)

df_out = pd.DataFrame(set_data)
df_out.to_excel('去重.xlsx', index=False)

标签:set,df,list1,列表,pd,字符串,list2,append
From: https://www.cnblogs.com/tiansz/p/16832597.html

相关文章