Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

dataframe unique values in each column

for col in df:
    print(df[col].unique())
Comment

python - subset dataframe based on unique value of a clumn

# Keep first duplicate value
my_df = my_df.drop_duplicates(subset=['my_var'])

# Keep last duplicate value
my_df = my_df.drop_duplicates(subset=['my_var'], keep='last')

# Remove all duplicate values
my_df = my_df.drop_duplicates(subset=['my_var'], keep=False)
Comment

dataframe python unique values rows

# get the unique values (rows)
df.drop_duplicates()
Comment

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
Comment

PREVIOUS NEXT
Code Example
Python :: get the name of a current script in python 
Python :: python getattr 
Python :: run python.py file 
Python :: herencia python 
Python :: python array extend 
Python :: To visualize the correlation between any two columns | scatter plot graph 
Python :: python tic tac toe 
Python :: showing specific columns pandas 
Python :: catalan number 
Python :: python input code 
Python :: opencv shift image python 
Python :: read excel spark 
Python :: how to change index date format pandas 
Python :: python submit work to redis 
Python :: seconds to datetime.time 
Python :: flask cookies 
Python :: opencv google colab 
Python :: python 3d array 
Python :: python file hashlib 
Python :: remove dot from number python 
Python :: discord python tts 
Python :: python tkinter projects 
Python :: python constructor overloading 
Python :: pyplot python 
Python :: extract email address using expression in django 
Python :: index a dictionary python 
Python :: pandas convert numbers in parentheses to negative 
Python :: how to check substring in python 
Python :: geopandas stack or concatenate dataframe together 
Python :: matplotlib vertical tick labels 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =