pip install pandas
pip install xlrd

大量记录的时候,用EXCEL排序处理比较费劲,EXCEL程序动不动就无响应了,用pands完美解决。

# We will use data structures and data analysis tools provided in Pandas library
import pandas as pd # Import retail sales data from an Excel Workbook into a data frame
# path = '/Documents/analysis/python/examples/2015sales.xlsx'
path = 'F:/python/an.xlsx'
xlsx = pd.ExcelFile(path)
df = pd.read_excel(xlsx, 'Sheet1') # Let's add a new boolean column to our dataframe that will identify a duplicated order line item (False=Not a duplicate; True=Duplicate)
df['is_duplicated'] = df.duplicated(['ip']) # We can sum on a boolean column to get a count of duplicate order line items
# df['is_duplicated'].sum() # Get the records of duplicated, If you need non-dup just use False instead
df_dup = df.loc[df['is_duplicated'] == True] # Finally let's save our cleaned up data to a csv file
df_dup.to_csv('dup.csv', encoding='utf-8')

ref:https://33sticks.com/python-for-business-identifying-duplicate-data/

 

Python pandas 获取Excel重复记录的更多相关文章

  1. Pandas标记删除重复记录

    Pandas提供了duplicated.Index.duplicated.drop_duplicates函数来标记及删除重复记录 duplicated函数用于标记Series中的值.DataFrame ...

  2. Python Pandas操作Excel

    Python Pandas操作Excel 前情提要 ☟ 本章使用的 Python3.6 Pandas==0.25.3 项目中需要用到excel的文件字段太多 考虑到后续字段命名的变动以及中文/英文/日 ...

  3. oracle数据据 Python+Pandas 获取Oracle数据库并加入DataFrame

    import pandas as pd import sys import imp imp.reload(sys) from sqlalchemy import create_engine impor ...

  4. Python用pandas获取Excel数据

    import pandas as pd df1 = pd.DataFrame(pd.read_excel(r'C:\python测试文件\我的三国啊.xlsx',sheet_name='Sheet1' ...

  5. python pandas 读excel类

    import pandas as pd '''特例说明 file1="a20201220.xlsx" sheetname='Sheet1' df=pd.read_excel(fil ...

  6. python pandas读写excel

    import pandas as pd import numpy as np df = pd.read_csv("result.csv") # csv # df = pd.read ...

  7. python pandas写入excel文件

    pandas读取.写入csv数据非常方便,但是有时希望通过excel画个简单的图表看一下数据质量.变化趋势并保存,这时候csv格式的数据就略显不便,因此尝试直接将数据写入excel文件. pandas ...

  8. 【划重点】Python pandas简介

    一.pandas获取Excel表单的两种方式 import pandas as pd df1 = pd.DataFrame(pd.read_excel(r'C:\Users\ASUS\Desktop\ ...

  9. Python 使用Pandas读取Excel的学习笔记

    这里介绍Python中使用Pandas读取Excel的方法 一.软件环境: OS:Win7 64位 Python 3.7 二.文件准备 1.项目结构: 2.在当前实验文件夹下建立一个Source文件夹 ...

随机推荐

  1. 51nod 1201 整数划分

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1201 DP转移方程:dp[i][j] = dp[i-j][j]+dp[i ...

  2. ML | spectral clustering

    What's xxx In multivariate statistics and the clustering of data, spectral clustering techniques mak ...

  3. GPP加密破解工具gpp-decrypt

    GPP加密破解工具gpp-decrypt   GPP是Group Policy Preferences(组策略首选项)的缩写,这是一个组策略实施工具.通过该工具,网络管理员可以实现更多的网络管理,如驱 ...

  4. xshell配置

    字体:DejaVu Sans Mono 或者 Consolas 11号

  5. vbox在共享文件夹设置链接报错Protocol error问题

    环境: 基于VBox 的 vagrant (centos版本)开发环境. 问题: Virtualbox 虚拟机(centOS)中,在进行go程序编译的时候,需要设置一个链接符,然后得到了如下的错误: ...

  6. PhantomJS 基础及示例 (转)

    概述 PhantomJS is a headless WebKit scriptable with a JavaScript API. It has fast and native support f ...

  7. GO -- socket读取内容

    func handleRead(conn net.Conn, done chan string) { for { buf := make([]) reqLen, err := conn.Read(bu ...

  8. ActiveX控件打包成Cab置于网页中自动下载安装 [转]

    http://blog.sina.com.cn/s/blog_520c32270100nopj.html 做过ActiveX控件的朋友都知道,要想把自己做的ActiveX控件功能放在自己的网页上使用, ...

  9. IDG | 四则运算表达式计算

    分析 首先将中缀表达式转换为后缀表达式(逆波兰式),然后使用栈进行计算. 没有考虑括号.小数. 代码 import java.util.LinkedList; import java.util.Lis ...

  10. 怎样在ubuntu 系统上为 php 加上 redis 扩展

    近期一个项目.,想用redis 作为数据库,php是不待redis 扩展,必须安装,怎么安装呢?我在网上找的非常多资料发现都是预编译的.但都没成功.于是就找了第二种方法是不须要编译直接安装就能够了. ...