import pandas as pd
import numpy as np
##1.检测处理重复值:
right = pd.DataFrame({'key1': ['K0', 'K1', 'K1', 'K2'],
'key2': ['K0', 'K0', 'K0', 'K0'],
'C': [1, 1, 2, 3],
'D': [2, 2, 4, 6],
'E': [1, 1, 2, 3]})
data_drop = right['key1'].drop_duplicates(keep=False)
# keep:保留第几个重复值,默认为first,last,false:都不保留
print(len(data_drop))
# 表去重:===>>去行
shape_det = right.drop_duplicates(subset=['key1','key2'])
# print(shape_det)
# 特征重复:==>>去列(计算相似度)
# corr_det = right[['C','D','E']].corr(method='kendall') ##spearman
# print(corr_det)
detail = pd.read_excel('meal_order_detail.xlsx',sheet_name=0)
# 1.相似度矩阵
corr_det = detail[['counts','amounts','
数据清洗练习
最新推荐文章于 2024-02-25 01:06:18 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)