I'm new to Pandas/Python but am familiar with excel and what I'm trying to accomplish is essentially a v-lookup. I have a list of contract numbers that need to be compared to determine if each item in list A is in list B exactly time, if the item in list be has been matched to an item in list A then it cannot be matched again.
coll = []
coll = pd.DataFrame(coll)
coll = coll.append([cardpay, achpay])
audit0 = []
audit0 = coll["Policy #"]
audit0 = audit0.dropna()
audit0 = pd.DataFrame(audit0)
coll = coll.append([saves])
coll.sort_values("UserName")
coll = coll.reset_index(drop=True)
audit1 = []
audit1 = coll["PolicyNumber"]
audit1 = audit1.dropna()
audit1 = pd.DataFrame(audit1)
all of the data required is stored and sorted above
audit0 & 1 are redundant but make it easier to view for me
The count in "PolicyNumber" and "Policy #" do not match which has led to some issues in the
attempted solutions below
solution below leaves "Payment?" empty when prtined
coll["Payment?"] = np.where((coll["PolicyNumber"].str.contains(str(audit0))), "yes", "no")
Solution below did not work but read this approach was not ideal along my trials
for i, row in coll["PolicyNumber"]:
if i == coll.loc[coll["Policy #"]]:
print(True)
This gave error because the series are not of the same size(shape)
coll["Payment?"] = coll.merge(coll[["PolicyNumber", "Policy #"]], on=["Policy #"],
how="right")
Any advice or maybe additional clarity on related posts that may answer my question already?