I have a dataframe that contains Item Id numbers with multiple tasks and completion dates for those tasks. I am trying to assign categories based on task completions or in-completions in a separate column
my data frame looks like this:
Item ID Task 1 Comp Date Task 2 Comp Date Task 3 Comp Date
12781463 NaT NaT NaT
10547725 6/6/2019 7/30/2019 8/1/2019
12847251 5/31/2019 6/12/2019 NaT
12734403 5/31/2019 NaT NAT
to test my approach to my challenge i took a subset of my data set and wrote a portion of the function that will be used with pd.apply(). below is some sample code for my .apply() function
def gating(row):
if row['Task 1 Comp Date'].isnull():
return "Pending Task 1"
if row['Task 3 Comp Date'] .notnull():
return "Complete"
df['Gating'] = df.apply(gating, axis = 1)
i was expecting to see a value of "Complete" for Item ID10547725 but got
AttributeError: ("'Timestamp' object has no attribute 'notnull'", 'occurred at index 8')
Is there a different approach i should take?