Python pandas 获取Excel重复记录
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重复记录的更多相关文章
- Pandas标记删除重复记录
Pandas提供了duplicated.Index.duplicated.drop_duplicates函数来标记及删除重复记录 duplicated函数用于标记Series中的值.DataFrame ...
- Python Pandas操作Excel
Python Pandas操作Excel 前情提要 ☟ 本章使用的 Python3.6 Pandas==0.25.3 项目中需要用到excel的文件字段太多 考虑到后续字段命名的变动以及中文/英文/日 ...
- oracle数据据 Python+Pandas 获取Oracle数据库并加入DataFrame
import pandas as pd import sys import imp imp.reload(sys) from sqlalchemy import create_engine impor ...
- Python用pandas获取Excel数据
import pandas as pd df1 = pd.DataFrame(pd.read_excel(r'C:\python测试文件\我的三国啊.xlsx',sheet_name='Sheet1' ...
- python pandas 读excel类
import pandas as pd '''特例说明 file1="a20201220.xlsx" sheetname='Sheet1' df=pd.read_excel(fil ...
- python pandas读写excel
import pandas as pd import numpy as np df = pd.read_csv("result.csv") # csv # df = pd.read ...
- python pandas写入excel文件
pandas读取.写入csv数据非常方便,但是有时希望通过excel画个简单的图表看一下数据质量.变化趋势并保存,这时候csv格式的数据就略显不便,因此尝试直接将数据写入excel文件. pandas ...
- 【划重点】Python pandas简介
一.pandas获取Excel表单的两种方式 import pandas as pd df1 = pd.DataFrame(pd.read_excel(r'C:\Users\ASUS\Desktop\ ...
- Python 使用Pandas读取Excel的学习笔记
这里介绍Python中使用Pandas读取Excel的方法 一.软件环境: OS:Win7 64位 Python 3.7 二.文件准备 1.项目结构: 2.在当前实验文件夹下建立一个Source文件夹 ...
随机推荐
- spring boot--日志、开发和生产环境切换、自定义配置(环境变量)
Spring Boot日志常用配置: # 日志输出的地址:Spring Boot默认并没有进行文件输出,只在控制台中进行了打印 logging.file=/home/zhou # 日志级别 debug ...
- js-关于微信页面分享(取消或打开)
在微信二次开发中,我们会遇到页面可以分享或不能分享的情况(私人隐私页面不能.禁止分享) 1.禁止页面分享(取消微信开打页面的分享功能) <script> function onBridge ...
- js中cookie、sessionStorage、localStorage
一.cookie <!DOCTYPE html> <html> <head> <meta charset="utf-8"> < ...
- python3 - 多线程和协程速率测试对比
多线程和协程都属于IO密集型,我通过以下用例测试多线程和协程的实际速率对比. 实例:通过socket客户端以多线程并发模式请求不同服务器端(这里服务器端分2种写法:第一种服务器通过协程实现,第二种服务 ...
- bzoj 1552: [Cerc2007]robotic sort
1552: [Cerc2007]robotic sort Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 1198 Solved: 457[Submit] ...
- 使用python一步一步搭建微信公众平台
https://my.oschina.net/yangyanxing/blog/159215 http://www.ziqiangxuetang.com/django/python-django-we ...
- iOS真机测试,为Provisioning添加设备
------------添加设备到provisioning------------- 1,登陆https://developer.apple.com/devcenter/ios/index.actio ...
- android ListView详解(转)
在android开发中ListView是比较常用的组件,它以列表的形式展示具体内容,并且能够根据数据的长度自适应显示.抽空把对ListView的使用做了整理,并写了个小例子,如下图. 列表的显示需要三 ...
- layer的alert、prompt等操作如何响应键盘的回车和ESC操作
layer.prompt({title: '请输入数据', formType: 1, //隐藏用户输入内容 // 这个是确定按钮的事件 "success":function(){ ...
- mac下报错 xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
如题mac下遇到错误: 解决办法:安装mac的命令行工具CommandLineTools xcode-select --install