Get micro seconds from timestamp in pandas python

dt.microsecond  is the inbuilt method to get micro seconds from timestamp in Pandas Python.  Let’s see how to

  • Get the micro seconds from timestamp in pandas python

First lets create the dataframe

import pandas as pd
import numpy as np
import datetime

date1 = pd.Series(pd.date_range('2012-1-1 11:20:50', periods=7, freq='ms'))
df = pd.DataFrame(dict(date_given=date1))
print(df)

so the resultant dataframe will be

Get micro seconds from timestamp in pandas python

 

microsecond function gets the micro seconds value of the timestamp


df['microseconds_of_timestamp'] = df['date_given'].dt.microsecond
print(df)

so the resultant dataframe will be

Get micro seconds from timestamp in pandas python 2

 

Get micro seconds from timestamp in pandas python                                                                                                                Get micro seconds from timestamp in pandas python