您现在的位置是:热点 >>正文
总结了Pandas实现数据清洗的7种方式
热点7557人已围观
简介...
最近在做“对比excel,学习pandas系列”,前面发了一篇 很受读者喜爱,今天给大家介绍一下excel和pandas实现数据清洗的种方式
1.处理数据中的空值
我们在处理真实总结的数据时,往往会有很多缺少的的特征数据,就是所谓的空值,必须要进行处理才能进行下一步分析
空值的处理方式有很多种,一般是删除或者填充
Excel通过“查找和替换”功能实现空值的统了P一替换:
通过“定位”删除空值:
pandas处理空值的方式比较灵活,可以使用dropna函数删除空值
import pandas as pd&nbsanp;data=pd.read_csv('成绩表.csv',encoding='gbk') data.dropna(how='any')
用fillna函数da实现空值的填充
①使用数字0填充数据表中的空值
data.fillna(value=0)
②使用平均值填充数据表中的空值
data['语文'].fils实lna(data['语文'].mean())
2.删除空格
excel中清理空格很简单,直接替换即可
pandas删除空格也很方便,主要使用map函数
data['姓名'现数]=data['姓名'].map(str.strip) data
3.大小写转换
excel中大小写转换函数分别为upper()和lower()
panda据清s中转换函数也为upper()和lower()
data['拼音']=data['拼音'].str.upper() data
data['拼音']=dat洗的a['拼音'].str.lower() data
4.更改数据格式
excel中更改数据格式通过快捷键“ctrl+1”打开“设置单元格格式”:
pandas使7种用astype来修改数据格式,以将“语文”列改成整数为例
data['语文'].dropna(how='any').astype('int')
5.更改列名称
exc方式el中更改列名称就不说了,大家都会
pandas使用rename函数更改列名称,代码如下:
data.rename(columns={'语文':'语文成绩'})
6.总结删除重复值
excel的功能区“数据”下有“删除重复项”,可以用来删除表中的重复值,默认保留最第一个重复值,把后面的删除:
pandas使用drop_duplicates函数删除重复值了P:
data['数学'].drop_duplicates() #默认删除后面的重复值 data['数学'].drop_duplicates(keep=an'last') #删除第一项重复值 7.修改及替换数据
excel中使用“查找和替换”功能实现数值的替换
pandas中使用replace函数实现数据替换
data['da姓名'].replace('成 功','失 败')
Tags:
相关文章
标签: 苹果 iPhone 17 Pro 换购 折抵
热点云梦级10月31日云梦级消息,近日,有网友发帖反馈称,在苹果官网买新机参与换购活动,结果反被坑。 这位网友表示,他在苹果官网购买 11999 元的 iPhone 17 Pro Max 时显示旧 iPh...
【热点】
阅读更多云计算开发:Python3随机数函数random()方法详解
热点描述 random() 方法返回随机生成的一个实数,它在半开放区间 [0,1) 范围内。 语法 以下是 random() 方法的语法: import random random.random() 注意...
【热点】
阅读更多云安全日报211111:红帽企业高级集群管理解决方案发现重要漏洞,需要尽快升级
热点Red Hat Advanced Cluster Management是红帽公司的一个控制台集群控制软件。这是红帽专为混合云环境设计的IT管理技术产品系列的最新成员,它能帮助企业利用跨混合云和多云环境...
【热点】
阅读更多
热门文章
最新文章
友情链接
- 标签: 康师傅
- https://www.remit.co.jp/vi/?s=谷歌霸屏外推技术【tg:seogoogle987】,brZ
- https://www.le-trend.com/en/search/=谷歌霸屏外推技术【tg:seogoogle987】,3Tc
- https://www.world-architects.com/en/search?term=谷歌霸屏外推技术【tg:seogoogle987】,QeV
- https://www.sweat.com/collections/vendors?q=谷歌霸屏外推技术【tg:seogoogle987】,ydq
- https://www.remit.co.jp/ne/?s=谷歌霸屏外推技术【tg:seogoogle987】,yde
- https://hsmoa.com/search?query=谷歌霸屏外推技术【tg:seogoogle987】5pP
- https://www.therapeuticassociates.com/?cat=5&s=谷歌霸屏外推技术【tg:seogoogle987】,aYT
- https://www.ushmm.org/search/results/?ID=8s0587Oi8UTv74zPPM4fuhwjNpe2hsEE&q=谷歌霸屏外推技术【tg:seogoogle987】,Okx
- https://www.vfw.org/search-results?q=谷歌霸屏外推技术【tg:seogoogle987】,MLv
- https://yokohama-oht.com/?action=CHECK&s=谷歌霸屏外推技术【tg:seogoogle987】,669
- https://www.urmc.rochester.edu/news/search?q=谷歌霸屏外推技术【tg:seogoogle987】,mGA
- https://www.ng-slo.si/si/iskanje?cat=114&q=谷歌霸屏外推技术【tg:seogoogle987】,1uF
- https://www.teamlab.art/ko/?submit=谷歌霸屏外推技术【tg:seogoogle987】,JbE
- https://www.duksung.ac.kr/search/front/Search.jsp?qt=谷歌霸屏外推技术【tg:seogoogle987】53O
- https://www.kaliastyle.com/catalogsearch/result/?q=GOOGLE谷歌霸屏外推技术【tg:seogoogle987】,Uec
- https://www.pickett.co.uk/collections/vendors?q=谷歌霸屏外推技术【tg:seogoogle987】,5MT
- https://www.kubb-tool.bfs.admin.ch/en/search?action=CHECK&q=谷歌霸屏外推技术【tg:seogoogle987】,GU7
- https://www.so.com/s?ie=utf-8&src=360sou_home&_re=0&q=谷歌霸屏外推技术【tg:seogoogle987】,Mup
- https://www.zisha.com/shop/list.shtml?wap_keyword=谷歌霸屏外推技术【tg:seogoogle987】,7l8
- https://www.wikiart.org/pt/Search/谷歌霸屏外推技术【tg:seogoogle987】,1i1
- https://xn--lgernevedlystskoven-lxb.dk/search/谷歌霸屏外推技术【tg:seogoogle987】,hOD
- https://www.southmeadows.co.uk/2019/07/?s=谷歌霸屏外推技术【tg:seogoogle987】,JMJ
- https://www.qylaws.com/search/谷歌霸屏外推技术【tg:seogoogle987】,Lw3
- https://5gaa.org/?token=6e2l7hjt2i26gzgctgwdrv7v0j6nxorq&s=谷歌霸屏外推技术【tg:seogoogle987】UlP
- https://www.tycoonstory.com/?s=谷歌霸屏外推技术【tg:seogoogle987】,dXW
- https://www.udc.co.uk/index.php?route=product/search&sort=p.price&order=DESC&tag=谷歌霸屏外推技术【tg:seogoogle987】,rRh
- https://www.valuecolleges.com/?action=QUERY&s=谷歌霸屏外推技术【tg:seogoogle987】,4tz
- https://www.flickr.com/photos/tags/谷歌霸屏外推技术【tg:seogoogle987】fm2
- https://www.kelsa.co.uk/catalogsearch/result/index/?T=1686132119291&q=谷歌霸屏外推技术【tg:seogoogle987】,gDb
- https://www.partilerdunyasi.com/index.php?route=product/search&tag=谷歌霸屏外推技术【tg:seogoogle987】,guU
- https://www.remit.co.jp/zh/?s=谷歌霸屏外推技术【tg:seogoogle987】,qmf
- https://www.sebson.de/en/search?query=谷歌霸屏外推技术【tg:seogoogle987】,Uio
- https://www.libros.unam.mx/catalogsearch/result/?cat=37&dir=asc&format=20&lit=20&manufacturer=3230&mode=list&order=year_edition&q=谷歌霸屏外推技术【tg:seogoogle987】,op8
- https://www.roblox.com/discover/?cat=107&Keyword=谷歌霸屏外推技术【tg:seogoogle987】,PyK
- https://www.oprny.com/search.php?search_query=谷歌霸屏外推技术【tg:seogoogle987】,Cpb
- https://www.lauben.com/en/?action=SEARCH&s=谷歌霸屏外推技术【tg:seogoogle987】,74Y
- https://wydden.com/?ID=r8w9WMSKWkOcmiaFWaUv0dzMdqZWfKtF&s=谷歌霸屏外推技术【tg:seogoogle987】,uKm
- https://www.solerpalau.com/en-en/catalogsearch/result/?q=谷歌霸屏外推技术【tg:seogoogle987】,if1
- https://www.rhymezone.com/r/rhyme.cgi?typeofrhyme=oldrel&loc=nojs&Word=谷歌霸屏外推技术【tg:seogoogle987】,OA1
- https://www.televes.com/es/catalogsearch/result/?q=谷歌霸屏外推技术【tg:seogoogle987】,h7U
- https://www.whirlpool.com.hk/chinese/catalogsearch/result?cat=30&q=谷歌霸屏外推技术【tg:seogoogle987】,f26
- https://www.maafushidive.com?collections?vendors?q=谷歌霸屏外推技术【tg:seogoogle987】,MXc
- https://www.pierreherme.com/catalogsearch/result/?q=谷歌霸屏外推技术【tg:seogoogle987】,kkC
- https://www.oikos-tecnics.com/?s=谷歌霸屏外推技术【tg:seogoogle987】,Uyg
- https://www.tumblr.com/tagged/谷歌霸屏外推技术【tg:seogoogle987】,j1L
- https://www.wmfe.org/?s=谷歌霸屏外推技术【tg:seogoogle987】,7L0
- https://www.resilienz-akademie.com/?cat=71&s=谷歌霸屏外推技术【tg:seogoogle987】,5sH
- https://www.kawainter.com/catalogsearch/result/?q=谷歌霸屏外推技术【tg:seogoogle987】,rOU
- https://www.rockngem.com/?action=CHECK&s=谷歌霸屏外推技术【tg:seogoogle987】,60H
- https://www.lyrics.com/lyrics/谷歌霸屏外推技术【tg:seogoogle987】,QfE