Python .csv文件合并重复行并计数
import pandas as pd
df=pd.read_csv(“旧表.csv”,encoding=‘gbk’)
df[‘列名1’].groupby(df[‘列名2’]).count().sort_values(ascending=False).to_csv(“新表.csv”)
Python .csv文件合并重复行并计数
import pandas as pd
df=pd.read_csv(“旧表.csv”,encoding=‘gbk’)
df[‘列名1’].groupby(df[‘列名2’]).count().sort_values(ascending=False).to_csv(“新表.csv”)