I have a date frame like that has a submit and resolved date
Incident ID Submit_Date Resolved_Date INC001. 2021-02-25 2021-03-02 INC002 2021-02-27 2021-03-01 INC003 2021-02-27 NaT INC004 2021-04-01 NaT
I have a function to count the tickets if they meet a certain criteria but with the NaT's it won't read them with the comparison
part of the function I am having problems is like this The function it is looking if the rows resolved date is empty and the other tickets resolved date is empty then summing it for a count in a new column
result = list() for row in df.iterrows(): cur_data = row[1] result.append(((cur_data['Resolved_Date'] is pd.NaT) & (df['Resolved_Date'] is pd.NaT))).sum()) df['Count'] = result
I want the result to look like this
Incident ID Submit_Date Resolved_Date Count INC001 2021-02-25 2021-03-02 0 INC002 2021-02-27 2021-03-01 0 INC003 2021-02-27 NaT 2 # counting itself and the other NA resolved date INC004 2021-04-01 NaT 2 # counting itself and the other NA resolved date
Right now it is ignoring the NaTs
https://stackoverflow.com/questions/67411909/python-comparing-datetimes-with-nat-in-columns May 06, 2021 at 12:35PM
没有评论:
发表评论