I wrote the code below to basically check on a left join which fields did not have a match and create cpCheckIn in order to display those results. What I would like to do is then create a conditional statement that says, if that new dataframe (cpCheckIn) is NOT = 0 rows, then to create a new record in errorLog with the name of the process - let's say 'counterparty check' - and the date/time of the error.
import pandas as pd
import numpy as np
errorLog = pd.DataFrame(columns=['process', 'date/time'])
imports here of the data I need, but wanted to keep only the relevant code
Pos = pd.merge(Pos,
cpTrans,
how='left',
left_on='COUNTERPARTY',
right_on='ticker',
indicator='cpCheck')
cpCheckIn = Pos[Pos.cpCheck != 'both']
cpCheckIn = cpCheckIn.filter(['Position',
'COUNTERPARTY',
'ticker',
'counterparty_name',
'cpCheck'])
I have been trouble coming up with a solution here and wonder if I'm thinking about this in the correct order of events. Any advice is much appreciated, thanks!
Aucun commentaire:
Enregistrer un commentaire