Wednesday, January 21, 2026
HomeLanguagesPython | Pandas Timedelta.components

Python | Pandas Timedelta.components

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.components property in pandas.Timedelta is used to return a Components NamedTuple-like.

Syntax: Timedelta.components

Parameters: None

Returns: return a Components NamedTuple-like

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.components)


Output:

3 days 06:05:01.000030
Components(days=3, hours=6, minutes=5, seconds=1, milliseconds=0, microseconds=30, nanoseconds=0)

Code #2:




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


Output:

1 days 07:00:00
Components(days=1, hours=7, minutes=0, seconds=0, milliseconds=0, microseconds=0, nanoseconds=0)

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)) 
  
# Print the Timedelta object 
print(td) 
  
print(td.components)


Output:

3 days 07:00:08
Components(days=3, hours=7, minutes=0, seconds=8, milliseconds=0, microseconds=0, nanoseconds=0)

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32475 POSTS0 COMMENTS
Milvus
119 POSTS0 COMMENTS
Nango Kala
6847 POSTS0 COMMENTS
Nicole Veronica
11977 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12064 POSTS0 COMMENTS
Shaida Kate Naidoo
6986 POSTS0 COMMENTS
Ted Musemwa
7220 POSTS0 COMMENTS
Thapelo Manthata
6933 POSTS0 COMMENTS
Umr Jansen
6912 POSTS0 COMMENTS