Python pandas convert datetime to timestamp effectively through dt accessor

后端 未结 5 2095
别跟我提以往
别跟我提以往 2021-02-01 14:06

I have a dataframe with some (hundreds of) million of rows. And I want to convert datetime to timestamp effectively. How can I do it?

My sample df:

5条回答
  •  清歌不尽
    2021-02-01 15:00

    There's also another method to do this using the "hidden" attribute of DatetimeIndex called asi8, which creates an integer timestamp.

    pd.DatetimeIndex(df.datetime).asi8

    Wes McKinney suggested it in this tangentially related stackoverflow question linked here

提交回复
热议问题