Friday, December 27, 2024
Google search engine
HomeLanguagesPython | Pandas Timedelta.microseconds

Python | Pandas Timedelta.microseconds

Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.

Timedelta is a subclass of datetime.timedelta, and behaves in a similar manner. It is the pandas equivalent of python’s datetime.timedelta and is interchangeable with it in most cases. Timedelta.microseconds property in pandas.Timedelta is used to return Number of microseconds.

Syntax: Timedelta.microseconds

Parameters: None

Returns: return the Number of microseconds.

Code #1:




# importing pandas as pd 
import pandas as pd 
  
# Create the Timedelta object 
td = pd.Timedelta('3 days 06:05:01.000030'
  
# Print the Timedelta object 
print(td) 
  
print(td.microseconds)


Output:

3 days 06:05:01.000030
30

Code #2:




# importing pandas as pd 
import pandas as pd 
  
# Create the Timedelta object 
td = pd.Timedelta('1 days 7 hours 254.1245 seconds'
  
# Print the Timedelta object 
print(td) 
  
print(td.microseconds)


Output:

1 days 07:04:14.124500
124500

Code #3:




# importing pandas as pd 
import pandas as pd 
import datetime
  
# Create the Timedelta object 
td = pd.Timedelta(datetime.timedelta(days = 3, hours = 7, seconds = 8, microseconds = 545)) 
  
# Print the Timedelta object 
print(td) 
  
print(td.microseconds)


Output:

3 days 07:00:08.000545
545
Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments