Skip to content Skip to sidebar Skip to footer

How To Prevent Pandas From Converting Datetimes To Datetime64

Need I am trying to export a dataframe to a Parquet file, which will be consumed later in the pipeline by something that is not Python or Pandas. (Azure Data Factory) When I inges

Solution 1:

Try to force the dtype='object' when you use to_pydatetime:

df['ts'] = pd.Series(df.timestamp.dt.to_pydatetime(),dtype='object')

df.loc[0,'ts']

Output:

datetime.datetime(2021, 2, 19, 15, 7, 24, 719272)

Post a Comment for "How To Prevent Pandas From Converting Datetimes To Datetime64"