I have a very simple set of code that I'm trying to generate a result off of a timedelta.
currentdate = datetime.datetime.now()
currentdate = currentdate.strftime("%m/%d/%Y")
##I need this first bit for another portion of my code, so it's a little messy.
now = datetime.date.today()
now = datetime.datetime.strptime(currentdate,'%m/%d/%Y').date()
now = pd.to_datetime(now)
delta1 = timedelta(days=30)
delta2 = timedelta(days=59)
delta3 = timedelta(days=180)
outdated = timedelta(days=1)
Line_Down = pd.to_datetime(fulldf['Line_Down'])
After this, I have each column set to tell me whether the "Line_Down" column is a certain amount of days away from the current date, generating a TRUE or FALSE value. I've stripped the time from the dates to make things more readable.
dateout = Line_Down - now
fulldf['Priority1'] = (delta1 >= dateout)
fulldf['Priority2'] = (delta2 >= dateout)
fulldf['Priority3'] = (delta3 >= dateout)
This is the code I have to check for TRUE/FALSE which obviously doesn't work.
fulldf['Priority1'] = fulldf['Priority1'].apply(lambda x: str(x))
if (fulldf['Priority1']) == 'FALSE':
fulldf['Priority'] = '1'
The 'Priority' column just sets a number depending on how far away the "Line_Down" date is from the current date. However Python doesn't recognize "Priority1-3" as a boolean, so I can't parse it with any statement. It states (As I'm sure you've expected):
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
edit: I understand that it's trying to process the entire column at once, which creates the ambiguity. How do I get it to look at each row individually, to resolve the ambiguity?
How can I convert this to a string or boolean to process it? The raw TRUE/FALSE values are worthless to me, but that's all I seem to be able to get from a TimeDelta calculation.