Return Minimum Value of Timedelta Object in Python Pandas



To return the maximum value of the Timedelta object, timedelta.min 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('2 days 1 min 15 s 20 ns')

Return the minimum value

timedelta.min

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('2 days 1 min 15 s 20 ns')

# display the Timedelta
print("Timedelta...\n", timedelta)

# return the minimum value
res = timedelta.min

# display the minimum value
print("\nTimedelta (min value)...\n", res)

Output

This will produce the following code

Timedelta...
 2 days 00:01:15.000000020

Timedelta (min value)...
 -106752 days +00:12:43.145224193
Updated on: 2021-10-13T07:41:45+05:30

468 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements