
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Return Microseconds from Timedelta Object in Python Pandas
To return the microseconds from Timedelta object, use the timedelta.microseconds property. At first, import the required libraries −
import pandas as pd
TimeDeltas is Python’s standard datetime library uses a different representation timedelta’s. Create a Timedelta object
timedelta = pd.Timedelta('7 days 20 min 15 s 35 ms')
Return the microseconds value
timedelta.microseconds
Example
Following is the code
import pandas as pd # TimeDeltas is Python’s standard datetime library uses a different representation timedelta’s # create a Timedelta object timedelta = pd.Timedelta('7 days 20 min 15 s 35 ms') # display the Timedelta print("Timedelta...\n", timedelta) # return the microseconds value res = timedelta.microseconds # display the microseconds print("\nTimedelta (microseconds value)...\n", res)
Output
This will produce the following code
Timedelta... 7 days 00:20:15.035000 Timedelta (microseconds value)... 35000
Advertisements