Python | Pandas Series.unique ()

When parsing data, a user many times wants to see unique values ​​in a particular column, which can be done with the Pandas function unique() .

To download the CSV file you are using, click here.

Syntax: Series.unique()

Return Type: Numpy array of unique values ​​in that column

Example # 1: Using Series.unique ()
This example uses the unique () method to identify all types of unique values ​​in the Team column.

# pandas package import

import pandas as pd

# create data frame from CSV file

< code class = "plain"> data = pd.read_csv ( " employees.csv " )

# store a unique value in a variable

arr = data [ "Team" ]. unique ()

# print array

print (arr)

As shown in the output image, an array is returned with all the unique values ​​in the column.

Error and excluded Considerations:

  • This method only works for series, not data frames
  • As shown in the output, this method includes NULL as a unique value .