[Python] Convert a column of datetimes to epoch in Python

Discussão em 'Python' iniciado por Stack, Março 8, 2025.

  1. Stack

    Stack Membro Participativo

    I'm currently having an issue with Python. I have a Pandas DataFrame and one of the columns is a string with a date. The format is :


    "%Y-%m-%d %H:%m:00.000". For example : "2011-04-24 01:30:00.000"
    ​

    I need to convert the entire column to integers. I tried to run this code, but it is extremely slow and I have a few million rows.

    for i in range(calls.shape[0]):
    calls['dateint'] = int(time.mktime(time.strptime(calls.DATE, "%Y-%m-%d %H:%M:00.000")))


    Do you guys know how to convert the whole column to epoch time?

    Continue reading...

Compartilhe esta Página