Python | Pandas TimedeltaIndex.has_duplicates

Python | Pandas TimedeltaIndex.has_duplicates

In pandas, the TimedeltaIndex is an Index of timedeltas (differences between times). The TimedeltaIndex provides a .has_duplicates property that allows you to check if the TimedeltaIndex contains duplicate values.

The has_duplicates property returns a boolean value: True if there are any duplicate time deltas and False otherwise.

Here's how you can use it:

Example:

import pandas as pd # Create a TimedeltaIndex tdi = pd.TimedeltaIndex(['1 days', '2 days', '2 days', '3 days', '4 days']) # Check if TimedeltaIndex has duplicates print(tdi.has_duplicates) 

Output:

True 

In this example, since '2 days' appears twice in the TimedeltaIndex, the .has_duplicates property returns True.


More Tags

rabbitmq-exchange ignore-case led leap-year uinavigationitem defaultmodelbinder sqlcmd kill-process asp.net-core-3.0 scp

More Programming Guides

Other Guides

More Programming Examples