I have an Excel file with a column that contain both date and time in a single cells as follows:


I'm wondering how to extract this cell, split date and time (that are separated by a "T") and write them into 2 new columns "Date" and "Time", and able to use them afterwards to, for example, do Time math operations.

I'd have a start from pandas:

    df = pd.read_excel('file.xlsx')
    def convert_excel_time(excel_time):
    return pd.to_datetime()

but I actually don't know if it is achievable with pandas.

If I have this:

enter image description here

I would like to calculate how many minutes passed (for the same date) for the same ID column (2nd column).

I guess I can use python tdelta, or is there a pandas alternative?

Thank you.


1 Answer 1


Pandas can parse most dates formats using

import pandas as pd
pd.to_datetime(df["name of your date column"])

You can also cast the desired column to datetime64 which is Numpy dtype

df = df.astype({"column name": "datetime64"})
  • $\begingroup$ Thanks. df = df.astype({"column name": "datetime64"}) returned me a correct formatting. I updated my question - how to perform a tdelta operation in pandas or python? $\endgroup$
    – Steven
    Commented Jul 14, 2020 at 13:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.