要對比兩張表的不同數(shù)據(jù),可以使用Python的pandas庫來實(shí)現(xiàn)。下面是一個簡單的示例代碼:
import pandas as pd
# 讀取兩張表的數(shù)據(jù)
df1 = pd.read_excel('table1.xlsx')
df2 = pd.read_excel('table2.xlsx')
# 對比兩張表的不同數(shù)據(jù)
diff_df = pd.concat([df1, df2]).drop_duplicates(keep=False)
# 打印不同數(shù)據(jù)
print(diff_df)
在這個示例代碼中,首先使用pd.read_excel
函數(shù)讀取兩張表的數(shù)據(jù),你可以根據(jù)實(shí)際情況選擇適合的讀取函數(shù),比如pd.read_csv
讀取CSV文件。
然后,使用pd.concat
函數(shù)將兩張表的數(shù)據(jù)合并成一個DataFrame,并使用drop_duplicates
函數(shù)去除重復(fù)的數(shù)據(jù),這樣就得到了兩張表的不同數(shù)據(jù)。
最后,使用print
函數(shù)打印不同數(shù)據(jù),你可以根據(jù)需要對數(shù)據(jù)進(jìn)行進(jìn)一步的處理和分析。