Friday, November 21, 2025
HomeLanguagesPython | Pandas Timedelta.nanoseconds

Python | Pandas Timedelta.nanoseconds

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.nanoseconds property in pandas.Timedelta is used to return Number of nanoseconds.

Syntax: Timedelta.nanoseconds

Parameters: None

Returns: return the Number of nanoseconds.

Code #1:




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


Output:

3 days 06:05:01.000000
111

Code #2:




# importing pandas as pd 
import pandas as pd 
  
# Create the Timedelta object 
td = pd.Timedelta('7 days 15 min 3 s 42 ns'
  
# Print the Timedelta object 
print(td) 
  
print(td.nanoseconds)


Output:

7 days 00:15:03.000000
42

Code #3:




# importing pandas as pd 
import pandas as pd 
import datetime
  
# Create the Timedelta object 
td = pd.Timedelta(133, unit ='ns')
  
# Print the Timedelta object 
print(td) 
  
print(td.nanoseconds)


Output:

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

Most Popular

Dominic
32405 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6781 POSTS0 COMMENTS
Nicole Veronica
11928 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11996 POSTS0 COMMENTS
Shaida Kate Naidoo
6907 POSTS0 COMMENTS
Ted Musemwa
7166 POSTS0 COMMENTS
Thapelo Manthata
6862 POSTS0 COMMENTS
Umr Jansen
6847 POSTS0 COMMENTS