1

I want to convert the date to epoch ms and attach back to the dataframe how this be done.

     Date
        30/10/2019
        31/10/2019
        04/10/2019
        15/10/2019
        13/11/2019
        3/11/2019

Expected Output:

            Date         Epoch ms
            30/10/2019   1572413051
            31/10/2019
            04/10/2019
            15/10/2019
            13/11/2019
            3/11/2019

    I tried the ones listed reference questions

    import datetime as dt
    dt['epoch'] = (dt['Date'] - dt.datetime(1970,1,1)).dt.total_seconds().


    ---------------------------------------------------------------------------
    TypeError                                 Traceback (most recent call last)
    <ipython-input-37-77878a892b77> in <module>()
    ----> 1 dt['epoch'] = (dt['Date'] - dt.datetime(1970,1,1)).dt.total_seconds()

TypeError: 'module' object is not subscriptable

How can this be done ?

1

1 Answer 1

1

start with

import datetime

and end with the following. You might need to do some formatting-fu to get different parts of those strings into the function, but I'm confident you can do that if they are delimited the same way.

datetime.datetime(2019,04,01,0,0).strftime('%s')
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.