Python Pandas - Return the minimum value of the Timedelta object

PythonPandasServer Side ProgrammingProgramming

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
raja
Updated on 13-Oct-2021 07:41:45

Advertisements