NaTType does not support dst

Parul_ch
Level 3
NaTType does not support dst

Hi,

While running a python code: this is the snippet of the code

 datadump_df['TIME'] = pd.to_datetime(datadump_df['TIME'])
datadump_df.set_index('TIME', inplace=True)
datadump_df = datadump_df.resample('200ms').first()
datadump_df.loc[datadump_df['ROP_15MIN'] == 6553.0, 'ROP_15MIN'] = np.nan

getting this error at line 3:

<class 'ValueError'>: NaTType does not support dst

Kindly suggest.

Thanks,

Parul.

 

0 Kudos
1 Reply
Ignacio_Toledo

Hi @Parul_ch,

The problem is that you might have empty or null values in the column 'TIME' that you want to convert to a datetime.

pd.to_datetime, by default, won't continue to parse the dates and it will raise an error. Several options are available depending on what you need:

  • Remove empty values from your dataframe
  • Impute the missing values
  • If you don't mind having empty dates for the next steps of your data preparation, you can add the option 

 

pd.to_datetime(datadump_df['TIME'], errors='coerce')

 

This will ignore the error when parsing null values, and it will set those as NaT

Hope this helps!