I have been struggling with this question for a long while, and I tried different methods.
I have a simple DataFrame as shown,
I can use code to rep
Similar approach as suggested by @neerajYadav but without the apply:
apply
dfTest2['InvoiceDate'] = (dfTest2['InvoiceDate'] .astype(str) # <- cast to string to simplify # .replace() in newer versions .replace({'NaT': None} # <- replace with None )