Panda is not picking up date time (ie, I need to keep minutes and seconds), nor can I convert it.
import pandas as pd
rides = pd.read_parquet('../data/raw/rides_2022-01.parquet')
rides.head(20)
rides = rides[['pickup_datetime', 'PULocationID']]
rides.rename(columns={
'tpep_pickup_datetime': 'pickup_datetime',
'PULocationID': 'pickup_location_id',
}, inplace=True)
rides.to_datetime(rides['pickup_datetime']) <-- errors here AttributeError: 'DataFrame' object has no attribute 'to_datetime'
rides['pickup_datetime'].describe(include='all')
count 2463879
mean 2022-01-17 01:58:40.393673472
min 2022-01-01 00:00:08
25% 2022-01-09 15:37:56
50% 2022-01-17 12:11:54
75% 2022-01-24 13:49:37
max 2022-01-31 23:59:58
Name: pickup_datetime, dtype: object
>Solution :
This is the correct syntax
rides["pickup_datetime"] = pd.to_datetime(rides["pickup_datetime"])
rides.dtypes
Output:
pickup_datetime datetime64[ns]
...