Add this line so that if there are NaT values in the 'TicketDate' column, it converts to None rather than throwing an error.
df['TicketDate'] = df['TicketDate'].fillna(pd.NaT).apply( lambda x: x.strftime('%Y-%m-%d') if pd.notna(x) else None )