두 개의 DataFrame 비교하기

지리산근육곰·2022년 2월 16일
0
post-thumbnail

두개의 DataFrame 비교하기

from tqdm import tqdm
import pandas as pd
df_1 = {'col_0': [1, 2, 3, 4],
        'col_1': [10, 20, 30, 40],
        'col_2': [100, 200, 300, 400]}

df_1 = pd.DataFrame(df_1)

df_2 = {'col_0': [1, 2, 3, 4],
        'col_1': [10, 20, 35, 40],
        'col_2': [100, 200, 350, 400]}

df_2 = pd.DataFrame(df_2)
for j in tqdm(range(len(df_1.columns))):
    for i in range(len(df_1)):
        if df_1.iloc[i,j]!=df_2.iloc[i,j]:
            print()
            print(f"{i} row의 {j} column의 값이 불일치 합니다.")
            print(df_1.iloc[i,j])
            print(df_2.iloc[i,j])

0개의 댓글