Python data analysis actual combat - deduplicate a column of dataframe and count the number after deduplication (with source code and implementation effect)

Realize function

The deduplicated value and quantity of a certain column of dataframe

1. The deduplication value of a certain column of dataframe

df[""].unique()

2. The number of deduplicated values ​​in a column of dataframe

len(df[""].unique())

Implementation code

import pandas as pd

data = pd.DataFrame({'name':['wencky','stany','barbio'],
                      'age':[29,29,3],
                      'gender':['w','m','m']})

print(data)
print('age去重',data["age"].unique(),sep='\n')
print('去重后数量',len(data["age"].unique()),sep='\n')

achieve effect

 During my postgraduate study, I published 5 papers related to SCI data mining. Now a research institute is engaged in scientific research related to data mining. I have a certain knowledge and understanding of data mining. I will combine my own scientific research practice experience to share from time to time about python machine learning and deep learning. , Basic knowledge and cases of data mining.

Committed to only being original, understanding and learning in the simplest way, pay attention to the V subscription number: data miscellaneous forum, contact me for more skills and source code.

Guess you like

Origin blog.csdn.net/sinat_41858359/article/details/131084267