Dates from 1900-01-01 are added to my 'Time' after using df['Time'] = pd.to_datetime(phData['Time'], format='%H:%M:%S')

Viewed 1932

I am a self taught coder (for around a year, so new). Here is my data

phData = pd.read_excel('phone call log & duration.xlsx')
called from called to   Date    Time    Duration in (sec)
0   7722078014  7722012013  2017-07-01  10:00:00    303
1   7722078014  7722052018  2017-07-01  10:21:00    502
2   7722078014  7450120521  2017-07-01  10:23:00    56

The dtypes are:
called from                   int64
called to                     int64
Date                 datetime64[ns]
Time                         object
Duration in (sec)             int64
dtype: object

phData['Time'] = pd.to_datetime(phData['Time'], format='%H:%M:%S')


phData.head(2)

called from called to   Date    Time    Duration in (sec)
0   7722078014  7722012013  2017-07-01  1900-01-01 10:00:00 303
1   7722078014  7722052018  2017-07-01  1900-01-01 10:21:00 502

I've managed to change the 'Time' to datetime64[ns] but somehow dates have been added?? From where I have no idea? I want to be able to analyse the Date and Time using Pandas which I'm happy to do. To explore calls made between dates and time, frequency etc. I think also I will be able to save it so it will work in Orange3. But Orange3 won't recognise the Time as a time format. I've tried stripping out the 1900-01-01 but get an error saying it can only be done if an object. I think the Time isn't a datetime but a datetime.time ??? and I'm not sure why this matters and how to simply have 2 columns one Date and another Time, that Pandas will recognise for me to mine. I have looked at countless posts and that's where I found how to use pd.to_datetime and that my issue might be datetime.time but I'm stuck after this.

1 Answers
Related