xxxxxxxxxx
import pandas as pd
# Read the Excel file
df = pd.read_excel('path_to_excel_file.xlsx')
# Calculate the count of unique values in a specific column
unique_count = df['column_name'].nunique()
print("Unique count in Excel:", unique_count)
xxxxxxxxxx
# Counts the number of distinct values between cells A2 to A11
{=SUM(IF(A2:A11<>"",1/COUNTIF(A2:A11, A2:A11), 0))}
# Does the same thing as the previous formula.
=SUM(IF(FREQUENCY(MATCH(A2:A11,A2:A11,0),MATCH(A2:A11,A2:A11,0))>0,1))
Counts the number of distinct numeric values.
=SUM(IF(FREQUENCY(A2:A11,A2:A11)>0,1))
# Returns the count of distinct text values in a range.
{=SUM(IF(ISTEXT(A2:A11),1/COUNTIF(A2:A11, A2:A11),""))}