learn from https://www.kaggle.com/learn/pandas
上一篇:Pandas入门2(DataFunctions+Maps+groupby+sort_values) 缺少值的条目将被赋予值 完成了课程+练习,获得证书一张,继续加油!🚀🚀🚀文章目录
5. dtype 数据类型
print(wine_rev.price.dtype)
,float64
wine_rev.dtypes
,整张表,需要加复数s
!!!country object description object designation object points int64 price float64 province object region_1 object region_2 object taster_name object taster_twitter_handle object title object variety object winery object critic object test_id int32 dtype: object
object
astype()
,可以进行类型转换wine_rev.points.astype('float64')
0 87.0 1 87.0 2 87.0 3 87.0 4 87.0 ... 129966 90.0 129967 90.0 129968 90.0 129969 90.0 129970 90.0 Name: points, Length: 129971, dtype: float64
wine_rev.index.dtype
,索引的类型是dtype('int64')
6. Missing data 缺失值
6.1 查找缺失值 pd.isnull(),pd.notnull()
NaN
,是Not a Number
的缩写。这些NaN
值始终为float64
dtype。
要选择NaN
条目,可以使用pd.isnull()
,pd.notnull()
wine_rev[pd.isnull(wine_rev.country)]
6.2 填补缺失值 fillna(),replace()
wine_rev.region_2.fillna('Unknown')
,原始数据不改变wine_rev.taster_twitter_handle.replace("@kerinokeefe", "@kerino")
,把前者替换成后者7. Renaming and Combining 重命名、合并
7.1 Renaming 重命名
rename()
,可以把索引名、列名更改wine_rev.rename(columns={'points':'score'})
index
,wine_rev.rename(index={0:'michael',1:'ming'})
,index={字典}
rename_axis()
,可以更改行索引、列索引名称wine_rev.rename_axis("酒",axis='rows').rename_axis('特征',axis='columns')
7.2 Combining 合并数据
concat(),join() 和 merge()
canadian_youtube = pd.read_csv("../input/youtube-new/CAvideos.csv") british_youtube = pd.read_csv("../input/youtube-new/GBvideos.csv") pd.concat([canadian_youtube, british_youtube])
left = canadian_youtube.set_index(['title', 'trending_date']) right = british_youtube.set_index(['title', 'trending_date']) left.join(right, lsuffix='_CAN', rsuffix='_UK')
本网页所有视频内容由 imoviebox边看边下-网页视频下载, iurlBox网页地址收藏管理器 下载并得到。
ImovieBox网页视频下载器 下载地址: ImovieBox网页视频下载器-最新版本下载
本文章由: imapbox邮箱云存储,邮箱网盘,ImageBox 图片批量下载器,网页图片批量下载专家,网页图片批量下载器,获取到文章图片,imoviebox网页视频批量下载器,下载视频内容,为您提供.
阅读和此文章类似的: 全球云计算