我正在尝试进行对账,以确保我的 df 中的值是准确的。我根据以下对账将它们分开,VAT + ExclVAT (BTW) 是否使用以下代码加起来总计:
#cleaning df
df['ExclBTW'] = df['ExclBTW'].astype(str).str.replace(r"[^a-zA-Z0-9\$?!.,]", '')
df['BTW'] = df['BTW'].astype(str).str.replace(r"[^a-zA-Z0-9\$?!.,]", '')
df['Totaal'] = df['Totaal'].astype(str).str.replace(r"[^a-zA-Z0-9\$?!.,]", '')
#validation check
cols = ['ExclBTW', 'BTW','Totaal']
df[cols] = df[cols].apply(lambda x: pd.to_numeric(x, errors='coerce'))
df['Totaal'] = np.where(df['Totaal'] == df['ExclBTW'].astype(float) + df['BTW'].astype(float), df['Totaal'], np.nan)
#seperating based on validation check
d = r'C:\Users\Max12\Desktop\xml\pdfminer\UiPath\attachments\75090058\Status\PDFsend'
for path in os.listdir(d):
df['filepath'] = os.path.join(d, path)
#df['relfilepath'] = os.listdir( r'C:\Users\Max12\Desktop\xml\pdfminer\UiPath\attachments\75090058\Status\PDFsend')
dfresult = df.loc[~df['Totaal'].isnull()]
dfresult_secondlook = df.loc[df['Totaal'].isnull()]
dfresult_secondlook
有以下df时我有一个奇怪的错误:
ExclBTW BTW Totaal
97.90 20.56 118.46
这将输出到 dfresult_secondlook 数据帧:
只有我不知道为什么因为数字匹配?
请帮忙