0

My duration column in dataframe contains negative timedelta values as shown below:

NaT
00:27:03.466021
-1 days +23:57:26.139011
00:10:06.227683

How to replace negative dates to Null or NaT in dataframe column?

user2961127
  • 963
  • 2
  • 17
  • 29
  • 1
    Does this answer your question? [How to replace negative numbers in Pandas Data Frame by zero](https://stackoverflow.com/questions/27759084/how-to-replace-negative-numbers-in-pandas-data-frame-by-zero) – Rahul Bharadwaj Jan 12 '20 at 04:15

1 Answers1

0

Use below command

mask=df['duration'] < pd.Timedelta(0)
df['duration'].mask(mask)