How to convert pandas pd.Timestamp() to epoch timestamp

In order to convert a Pandas pd.Timestamp to a number representing seconds since epoch, use ts.timestamp():

import pandas as pd

# Example pandas timestamp
timestamp = pd.Timestamp('2024-05-28 12:34:56')

# Convert to epoch timestamp with second resolution
epoch_timestamp_ms = timestamp.timestamp() # 1716899696.0

Since this returns a float, you can just multiply it by 1000 to obtain a timestamp with millisecond resolution:

import pandas as pd

# Example pandas timestamp
timestamp = pd.Timestamp('2024-05-28 12:34:56')

# Convert to epoch timestamp with second resolution
epoch_timestamp_ms = timestamp.timestamp() * 1000. # 1716899696000.0