dataframe unique values in each column
for col in df:
print(df[col].unique())
dataframe unique values in each column
for col in df:
print(df[col].unique())
pandas distinct
>gapminder['continent'].unique()
array(['Asia', 'Europe', 'Africa', 'Americas', 'Oceania'], dtype=object)
pandas unique values to list
df.groupby('param')['column'].nunique().sort_values(ascending=False).unique().tolist()
dataframe python unique values rows
# get the unique values (rows)
df.drop_duplicates()
unique entries in column pandas
# Import modules
import pandas as pd
# Set ipython's max row display
pd.set_option('display.max_row', 1000)
# Set iPython's max column width to 50
pd.set_option('display.max_columns', 50)
# Create an example dataframe
data = {'name': ['Jason', 'Molly', 'Tina', 'Jake', 'Amy'],
'year': [2012, 2012, 2013, 2014, 2014],
'reports': [4, 24, 31, 2, 3]}
df = pd.DataFrame(data, index = ['Cochice', 'Pima', 'Santa Cruz', 'Maricopa', 'Yuma'])
df
#List unique values in the df['name'] column
df.name.unique()
unique rows in dataframe
In [33]: df[df.columns[df.apply(lambda s: len(s.unique()) > 1)]]
Out[33]:
A B
0 0 a
1 1 b
2 2 c
3 3 d
4 4 e
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us