Python pandas convert datetime to timestamp effectively through dt accessor

后端 未结 5 2109
别跟我提以往
别跟我提以往 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条回答
  •  猫巷女王i
    2021-02-01 14:52

    One option would be to use a lambda expressions like such

    df['datetime'] = df['datetime'].apply(lambda x: pd.Timestamp(x))
    

提交回复
热议问题