import pandas as pd
import pandasql as ps
current = pd.read_csv("cur.csv")
previous = pd.read_csv("pre.csv")
sql = """
select c.`Unnamed: 0` as name, c.sum as current, p.sum as previous, (c.sum - p.sum) as diff
from current as c left join previous as p
on c.`Unnamed: 0` = p.`Unnamed: 0`
order by diff desc
"""
pf = ps.sqldf(sql, locals())
pf
标签:Unnamed,sum,current,pd,Sql,数据处理,csv,pandas,previous
From: https://www.cnblogs.com/NoobSirPersonalBlog/p/17559469.html