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

pandas count distinct values in column

#column name ISSDTM
pd.to_datetime(df.ISSDTM, errors='coerce').dt.year

#result
0    2013
1    2013
2    2009
3    2009
Name: ISSDTM, dtype: int64 
Comment

PREVIOUS NEXT
Code Example
Python :: how to read text frome another file pythion 
Python :: python fill string with 0 left 
Python :: play mp3 file python 
Python :: how to delete a csv file in python 
Python :: panda categorical data into numerica 
Python :: what is pypy 
Python :: check python version kali linux 
Python :: numpy drop duplicates 
Python :: python django shell command 
Python :: set cookie in chrome 
Python :: read file from s3 python 
Python :: python rgb colors 
Python :: python warning 
Python :: calcutalte average python 
Python :: python ascii code to string 
Python :: python detect lines 
Python :: create age-groups in pandas 
Python :: sum of all multiples of 3 and 5 below 100 
Python :: concatenate dataframes 
Python :: python selenium headers 
Python :: pandas test for nan 
Python :: python palindrome 
Python :: dataframe nested json 
Python :: radio button pyqt 
Python :: how to close windows in selenium python without quitting the browser 
Python :: append a zeros column numpy 
Python :: mac catallina python3 
Python :: replace character in string python 
Python :: sqlite check if table exists 
Python :: how to get current date and time in python 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =