Change language

Python | Pandas TimedeltaIndex.nunique

| |

TimedeltaIndex.nunique() Pandas TimedeltaIndex.nunique() returns the number of unique elements in an object. This excludes the default NA values.

Syntax: TimedeltaIndex.nunique ()

Parameters:
dropna: Don’t include NaN in the count

Return: nunique: int

Example # 1: Use TimedeltaIndex.nunique () to find the number of unique values ​​in a given TimedeltaIndex.

# import pandas as pd

import pandas as pd

 
# Create TimedeltaIndex object

tidx = pd.TimedeltaIndex (data = [ ’06: 05: 01.0000 30’ , None , ’ 22 day 2 min 3us 10ns’

’+23: 59: 59.999999’ , None , ’ +12: 19: 59.999999’ ])

 
# Print the TimedeltaIndex object

print (tidx)

Output:

We will now use the TimedeltaIndex. nunique () to find the number of unique values ​​in the tidx object.

# find the number of unique values ​​
# in the tidx object.
tidx.nunique ()

Output:

As we can see in the output, TimedeltaIndex.nunique () returned the total number of unique values ​​in the tidx object.

Example # 2: Use TimedeltaIndex.nunique ( ) to find the number of unique values ​​in a given TimedeltaIndex.

# import pandas as pd

import pandas as pd

 
# Create TimedeltaIndex object

tidx = pd.TimedeltaIndex (data = [ None , ’1 days 06: 05: 01.000030’ , None ,

’1 days 02: 00: 00’ , ’21 days 06: 15: 01.000030’ ])

 
# Print the TimedeltaIndex object

print (tidx)

Output:

Now we will use the TimedeltaIndex .nunique () what would find the number of unique values ​​in the tidx object.

# find the number of unique values ​​
# in tidx object.
tidx.nunique ()

Output:

As we can see in the output, TimedeltaIndex.nunique () returned the total number of unique values ​​in the tidx object.

Shop

Learn programming in R: courses

$

Best Python online courses for 2022

$

Best laptop for Fortnite

$

Best laptop for Excel

$

Best laptop for Solidworks

$

Best laptop for Roblox

$

Best computer for crypto mining

$

Best laptop for Sims 4

$

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers

News


Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method