Skip to content

Instantly share code, notes, and snippets.

@aasthavar
Created February 23, 2023 07:05
Show Gist options
  • Select an option

  • Save aasthavar/37b72c756498172b8556109b47a1ce64 to your computer and use it in GitHub Desktop.

Select an option

Save aasthavar/37b72c756498172b8556109b47a1ce64 to your computer and use it in GitHub Desktop.
Data Processing - Unique Values
def unique_values(data):
total = data.count()
tt = pd.DataFrame(total)
tt.columns = ['Total']
uniques = []
for col in data.columns:
unique = data[col].nunique()
uniques.append(unique)
tt['Uniques'] = uniques
return(np.transpose(tt))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment