I have a data frame, but the headings can change dynamically, as such I am using i.loc for Columns 4 onwards.
My working code is:
cv.iloc[:,[4]] = cv['Allocation'].apply(lambda x: x if dt.strptime(dates[0], "%Y-%m-%d") <= dt.strptime('2021-12-31', "%Y-%m-%d") else 0)
This applies the contents of cv['Allocation'] if the first date in my list is <= the fixed date in the formula.
However, what i would like to do is swap the fixed date for a Panda Column I want this:
cv.iloc[:,[4]] = cv['Allocation'].apply(lambda x: x if dt.strptime(dates[0], "%Y-%m-%d") <= cv['Allocation Completion Date'] else 0)
If I do that, I get: 'ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().'