Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to get distinct value in a column dataframe in python

df.column.unique()
Comment

pandas get column values distinct

import pandas as pd

colors = {'color': ['green', 'blue', 'blue', 'red', 'green']}
df = pd.DataFrame.from_dict(colors)

print(df['color'].unique())
Comment

distinct rows in this DataFrame

# distinct rows in this DataFrame

df.distinct().count()
# 2
Comment

pandas distinct

>gapminder['continent'].unique()
array(['Asia', 'Europe', 'Africa', 'Americas', 'Oceania'], dtype=object)
Comment

PREVIOUS NEXT
Code Example
Python :: Taking a list of strings as input, our matching function returns the count of the number of strings whose first and last chars of the string are the same. Also, only consider strings with length of 2 or more. python 
Python :: convert price to float python 
Python :: install python 3.7 centos 
Python :: seaborn bar plot 
Python :: web crawler using python 
Python :: import time in python 
Python :: python letter to number in alphabet 
Python :: list of numbers 
Python :: python webbrowser close tab 
Python :: filter pandas dataframe 
Python :: axios django 
Python :: python push to list 
Python :: python raw string 
Python :: pandas column name equal to another column value 
Python :: how to make a program that identifies positives and negatives in python 
Python :: delete an element by value from a list if it made of white spaces python 
Python :: tensorflow_version 
Python :: streamlit python install 
Python :: qrcode.make python 
Python :: python substitute multiple letters 
Python :: program count the number of occurrences of a letter in a string python 
Python :: python dict append value 
Python :: pandas dataframe unique multiple columns 
Python :: how to update requirements.txt python 
Python :: Module "django.contrib.auth.hashers" does not define a "BcryptPasswordHasher" attribute/class 
Python :: pandas divide one column by another 
Python :: change the frequency to column in pandas 
Python :: django admin.py all fields 
Python :: how to fix Crypto.Cipher could not be resolved in python 
Python :: python regular expression remove numbers 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =