NaTType does not support dst

Parul_ch
Parul_ch Partner, Registered Posts: 34 Partner

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.

Answers

  • Ignacio_Toledo
    Ignacio_Toledo Dataiku DSS Core Designer, Dataiku DSS Core Concepts, Neuron 2020, Neuron, Registered, Dataiku Frontrunner Awards 2021 Finalist, Neuron 2021, Neuron 2022, Frontrunner 2022 Finalist, Frontrunner 2022 Winner, Dataiku Frontrunner Awards 2021 Participant, Frontrunner 2022 Participant, Neuron 2023 Posts: 415 Neuron
    edited July 17

    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!

Setup Info
    Tags
      Help me…