删除重复元素 drop_duplicates()
来源:互联网 发布:tf卡数据恢复软件 编辑:程序博客网 时间:2024/06/01 16:59
import pandas as pddf = pd.read_excel("合并fitment.xlsx")print(len(df))skus = df.SKU.drop_duplicates()result = []for sku in skus: df_sub = df[df.SKU == str(sku)] makes = df_sub.Make.drop_duplicates() for make in makes : df_sub_sub = df_sub[df_sub.Make == make] models = df_sub_sub.Model.drop_duplicates() for model in models: df_sub_sub_sub = df_sub_sub[df_sub_sub.Model ==model] year = df_sub_sub_sub.Year year_min = year.min() year_max = year.max() arr = [year_min, "-",year_max , make , model] s = ""+str(year_min)+" - "+str(year_max)+" "+ str(make)+" "+str(model) result.append([sku , s])df = pd.DataFrame(result , columns=["SKU","fitment"])df.to_csv("fitment_combine.csv" , index=False)
阅读全文
0 0
- 删除重复元素 drop_duplicates()
- Pandas之drop_duplicates:去除重复项
- 删除重复元素
- List删除重复元素
- 删除链表中重复元素
- arrayList重复元素删除
- 删除链表中重复元素
- 重复元素的删除
- 删除链表中重复元素
- 删除链表中重复元素
- 重复删除多余元素
- HashSet删除重复元素
- 删除链表中重复元素
- 删除重复元素,集合
- 重复元素的删除
- 删除vector重复元素
- 删除ArrayList中重复元素
- 删除数组中重复元素
- Maximum Binary Tree
- windows32位安装Tensorflow
- RMI
- linux下移植AM335的sgx驱动
- 机器学习实战:基于概率论的分类方法:朴素贝叶斯(源码解析,错误分析)
- 删除重复元素 drop_duplicates()
- Windows Server 2008 R2配置.Net环境
- 朴素贝叶斯分类(Naive Bayesian classification)及其python实现
- 动态select表达式(EF+Dto)
- memcache--定义from wiki
- 教师岗前培训心得体会
- Socket客户端
- 详解云数据库PostgreSQL (附9.5版架构图及外存图)
- Scala读取HDFS文件