熊猫压缩怎么使用

What is Pandas?Pandas is an open-source data analysis library for providing easy-to-use data structures and data analysis tools. It is dependent on other libraries like Numpy(Read about Few Things You Should Be Able to Do With the Numpy Library) and has optional dependencies.

什么是熊猫? Pandas是一个开源数据分析库,用于提供易于使用的数据结构和数据分析工具。 它依赖于其他库,例如Numpy(请阅读 您应该能够使用Numpy库完成的一些事情 ),并且具有可选的依赖项。

What pandas has to offer?- It has fast and efficient DataFrame object.- It allows efficient data wrangling.- It has high performance in data cleaning and data scraping.- Missing data can be handled efficiently with the use of Pandas.- It allows grouping by data for aggregation and transformations.- It performs very well in merging and joining of data.- It has time series functionality.

熊猫提供什么? -- 它具有快速高效的DataFrame对象。-它允许有效的数据整理。-它在数据清理和数据抓取方面具有高性能。-使用Pandas可以有效地处理丢失的数据。-它允许按数据分组以进行聚合和转换.-在合并和连接数据时表现非常好。-具有时间序列功能。

How to install Pandas?The easiest way to get Pandas set up is to install it through a package like the Anaconda distribution which is a cross platform distribution for data analysis and scientific computing or using pip as seen below.

如何安装熊猫? 设置Pandas的最简单方法是通过Anaconda发行版之类的软件包进行安装,该软件包是用于数据分析和科学计算的跨平台发行版,或者使用如下所示的pip。

pip install pandas

Data structures of PandasSome of the data structures available with Pandas are:

熊猫的数据结构熊猫可用的一些数据结构是:

Series: A series is a 1-dimensional labelled array that can hold data of any type. Its axis labels are collectively called an index.

系列 :系列是一维标记的数组,可以保存任何类型的数据。 它的轴标签统称为索引。

Data frames: A data frame is a 2-dimensional labelled data structure with columns

数据帧 :数据帧是带有列的二维标记数据结构

Panels: is a 3-dimensional container of data.

面板 :是3维数据容器。

Using PandasTo use pandas, it has to be imported in our coding environment. This is done conventionally with the following command:

使用熊猫要使用熊猫,必须将其导入我们的编码环境中。 通常,这是通过以下命令完成的:

import pandas as pd

What are Dataframes?Dataframe is a table. It has rows and columns. Each column in a dataframe is Series object, rows consist of elements inside Series. It can be constructed using dictionary with keys and values.

什么是数据框? 数据框是一个表。 它具有行和列。 数据框中的每一列都是Series对象,行由Series内部的元素组成。 可以使用带有键和值的字典来构造它。

It is illustrated below.

如下图所示。

df = pd.DataFrame({'hobbies': ['Playing piano', 'singing', 'movies'], 'likes': ['reading', 'writing', 'learning'], 'dislikes': ['laziness', 'lateness', 'dishonesty']})

To form series, use:

要形成系列,请使用:

data = pd.Series(['promise', 'ogooluwa', 'daniel'])

To read CSV files, use:

要读取CSV文件,请使用:

df = pd.read_csv('filename.csv')

Dataframe operations

数据框操作

Some dataframe operations is illustrated in the code snippets below

下面的代码段说明了一些数据框操作

#Importing pandasimport pandas as pd #Creating a dataframe with a dictionarydf = pd.DataFrame({'hobbies': ['Playing piano', 'coding', 'movies'], 'likes': ['reading', 'writing', 'learning'], 'dislikes': ['laziness', 'lateness', 'cheating']})#To check data types of data frames, use the below command:df.dtypes#To check the origin of a dataframe from the pandas library, use:type(df)#To see columns of a dataframe, use:df.columns#To create dataframe specifying the columns and index.. You can use #as illustrated below:data = [['Playing piano', 'singing', 'movies'], ['reading', 'writing', 'learning'], ['laziness', 'lateness', 'dishonesty']]df1 = pd.DataFrame(data, columns=['Promise', 'Michael', 'Gloria'], index=['hobbies', 'likes', 'dislikes'])#Indexing#To explicitly locate an element i.e to specifically locate an element, use:df1.loc[['likes']]#To implicitly locate an element, use:df1.iloc[[1]]

Filtering Data framesThe illustration to show filtering dataframes is seen in the below code snippets:

过滤数据帧在以下代码段中可以看到过滤数据帧的图示:

#Importing pandasimport pandas as pd #Data frame creationdata = [['Playing piano', 'singing', 'movies'], ['reading', 'writing', 'learning'], ['laziness', 'lateness', 'dishonesty']]df1 = pd.DataFrame(data, columns=['Promise', 'Michael', 'Gloria'], index=['hobbies', 'likes', 'dislikes'])#To transpose, use:df1.T#To filter with conditions, use this command:#df1[condition]

Arithmetic operationData frames take arithmetic operations row by columns of each frame being operated.Other operations is shown in the snippet below:

算术运算数据帧对每个要运算的帧逐行进行算术运算,其他操作如下面的代码段所示:

#Importing pandasimport pandas as pd import numpy as np#Data frame creationdata = [['Playing piano', 'singing', 'movies'], ['reading', 'writing', 'learning'], ['laziness', 'lateness', 'dishonesty']]df1 = pd.DataFrame(data, columns=['Promise', 'Michael', 'Gloria'], index=['hobbies', 'likes', 'dislikes'])#To give an overview of what is in the dataframe, use:df1.describe()#To sum what is in a dataframe, use:df1.sum()#To represent with a null using numpy, use:np.NaN  

Data cleaningNA is referred to as missing values in Pandas. It is used for simplicity and performance reasons. Data cleaning is a process of preparing data for analysis.This can be illustrated in the following code snippets:

数据清理 NA在熊猫中称为缺失值。 出于简化和性能的原因使用它。 数据清理是准备数据进行分析的过程,可以在以下代码段中进行说明:

# Importing pandasimport pandas as pd  import numpy as np# Data series creationdata = pd.Series(['singing', 'eating', 'lying'])#Data frame creationdf1 = pd.DataFrame(data, columns=['Promise', 'Michael', 'Gloria'], index=['hobbies', 'likes', 'dislikes'])# Removing Nan, use:data.dropNa()# To get true or false for not null values, use:data.notnull()data[data.notnull()]# The above the same asdata.dropNa()#drops all rows with Nan (You could add axis)data.dropNa(how="all")#To create random dataframe with 4 rows and 2 columnspd.DataFrame(np.random.rand(4, 2))#To drop Na where na appears 2 or more than 2 times in df1df1.dropna(thresh=2) #Forward fill i.e fills all Na with data just before the data. To forward fill, use:df1.fillna(method='ffill')#To fill with a limit, use:df1.fillna(method="ffill", limit=2) #Won't fill more than 2 elements#IT IS OFTEN BETTER TO FILL WITH MEAN THAN TO FILL WITH JUST DATA

Data WranglingTo manipulate data, we could:- Group by join- Combine- Pivot- Melt- Reshape

数据整理要操作数据,我们可以:-按连接分组-组合-枢轴-熔化-重塑

This is illustrated below:

如下图所示:

# Importing pandasimport pandas as pd  # To melt - To make data come down from the top. To do, use:melted = pd.melt(dataframe, ['key'])# Pivot - To reshape meltedmelted.pivot('key', 'variable', 'value')# To group by data, use:grouped = dataframe['data'].groupby(dataframe['key'])#To view what you've grouped and evaluated in a table, use:grouped.unstack()

Joins and Unions

加盟与工会

# Importing pandasimport pandas as pd  df1 = pd.DataFrame({'hobbies': ['Playing piano', 'singing', 'movies'], 'likes': ['reading', 'writing', 'learning'], 'dislikes': ['laziness', 'lateness', 'dishonesty']})df2 = pd.DataFrame(data, columns=['Promise', 'Michael', 'Gloria'], index=['hobbies', 'likes', 'dislikes'])data = [['Playing piano', 'singing', 'movies'], ['reading', 'writing', 'learning'], ['laziness', 'lateness', 'dishonesty']]# To join - To intersect two dataframes. To do, use:pd.merge(df1, df2)#Note : Make sure df2 has unique values before joining#To join on a particular key, use:pd.merge(df1, df2, on="key")#To join in another waypd.merge(df1, df2, left_on='name', right_on="name")#To outer join i.e to join and put 'Nan" wherever a key is not includedpd.merge(df1,df2, how = "outer")#To concat, where s1, s2, s3 are series, use:pd.concat([s1, s2, s3])

Date and TimeTo use date and time, we use:

日期和时间要使用日期和时间,我们使用:

from datetime import datetime, date, time

Operations of date and time is seen below:

日期和时间的操作如下所示:

# importing required librariesfrom datetime import datetime, date, timeimport pandas as pd#Datetime object dt = datetime(2019, 11, 25, 11, 36, 00, 00)dt.day#To stringify datetime object to specified formatdt.strftime('%d/%m/%Y %H:%M')#To perform difference in timedifference = datetime(2019, 1, 7) + datetime(2018, 6, 24, 8, 15)difference.daysstamp = datetime(2019, 1, 3)print (str(stamp))print(stamp.strftime('%Y-%m-%d'))#To strip time from any format to datetime format, use:value = '19-January-03'datetime.strptime(value, '%y-%B-%d')#This gives the best guess of a stripped timefrom dateutil.parser import parseparse('2011-January-03')#To create random series time seriests = pd.Series(np.random.randn(5), index=pd.date_range('1/1/2000', periods=5, freq='Q'))#Shifts first two time down:ts.shift(2)#Shifts first two time up:ts.shift(-2)

翻译自: https://medium.com/swlh/few-things-you-should-be-able-to-do-with-the-pandas-library-29354e350d1e

熊猫压缩怎么使用


http://www.taodudu.cc/news/show-4112651.html

相关文章:

  • 熊猫压缩网址
  • 熊猫压缩怎么使用_从命令行开始使用熊猫
  • 51单片机之共阳极静态数码管
  • STM32F103驱动四位共阳极数码管程序
  • c51单片机之数码管显示(共阳极数码管)
  • c语言编写数码管的现实函数,C语言实现一位共阳极数码管
  • AT89C51单片机共阳极数码管动态显示(汇编语言)
  • 共阳极数码管与共阴极数码管联合使用来循环显示数字00-99。
  • 八位一体共阳极数码管显示电子时钟+闹铃+温度检测
  • 共阳极数码管真值表
  • 四位共阳极数码管显示函数_单片机利用四位共阳极得数码管显示2016
  • 共阳极管的代码_1.共阳极数码管是将发光二极管的_____连接在一起,字符5的共阳代码为_____,字符2的共阴代码为 _____。...
  • 共阳极数码管计数器
  • Multisim基础 共阴极数码管是com_k,共阳极数码管是com_a
  • 四位共阳极数码管显示函数_DS1302,四位共阳极数码管显示时钟,可调时间
  • 共阳极管的代码_共阳极数码管显示数字程序的进化
  • 四位共阳极数码管显示函数_求各位大神指正,四位一体共阳极数码管数字钟程序,仿真能运行,实物就只显8个8,不动...
  • 共阳极数码管编码表_LED数码管你知道多少?
  • 两位共阳极数码管c语言,89c51驱动两位共阳极数码管倒计时显示程序,60秒到30秒能实现,但从30秒到90秒不能实现,请高手帮忙!...
  • 共阳极管的代码_共阳极数码管显示
  • 共阳极数码管显示0~9_《显示器件应用分析精粹》之(3)数码管静态显示
  • 共阳和共阴数码管详细段码(带图)
  • licecap免费+轻量+使用简单的录屏制作gif工具
  • [软件安装] 动态图像录制工具LICEcap
  • (9)LICEcap——PC端动图创建工具
  • 工具 · GIF录屏licecap for Mac
  • LICEcap 一款小巧的GIF屏幕录制软件
  • MAC 录屏工具,录制视频制作GIF—— LICEcap
  • licecap:截屏录制gif图片工具
  • MarkDown中使用gif的神器:LICEcap

熊猫压缩怎么使用_您应该可以使用熊猫库做的几件事相关推荐

  1. 熊猫压缩怎么使用_将Excel与熊猫一起使用

    熊猫压缩怎么使用 Excel is one of the most popular and widely-used data tools; it's hard to find an organizat ...

  2. 电脑pin码忘了登录不进系统_升级win10系统必须要做的5件事,装机、重装系统必知...

    Windows 10是一个崭新的操作系统,提供了很多新的革命性的功能,使其成为一个有吸引力的系统,很多用户都想安装使用.无论你是想尝试新的开始体验,还是只想和你的新助手Cortana(小娜)谈谈,在升 ...

  3. linux漏洞知乎_安装 Manjaro Linux 后必做的 6 件事 | Linux 中国

    你刚刚全新安装了 Manjaro Linux,那么现在该做什么呢? 作者:Dimitrios Savvopoulos 译者:Hilton Chain (本文字数:1579,阅读时长大约:2 分钟) 下 ...

  4. 带孩子们做环球旅行的读后感_带着孩子必须要做的5件事,你做了几件

    孩子的三观,未来发展,跟父母是息息相关的,主要看父母如何去做一个引导,如何去培养孩子,全靠父母接下来的用心程度,没有一个父母对孩子不上心的,只不过是不知道如何培养,引导孩子,只能心理着急,甚至是做一些 ...

  5. 本地缓存需要高时效性怎么办_唯品会三年,我只做了5件事,如今跳槽天猫拿下offer(Java岗)...

    前言 "xxx,都是好牌子,天天有三折" 是的,我在这家洗脑广告词公司里工作了整整三年时间,虽然是大家耳熟能详的互联网电商公司,但它的发展同其他新起互联网公司来说局限了很多,同时也 ...

  6. 熊猫压缩怎么使用_如何使用熊猫示例选择行和列

    熊猫压缩怎么使用 In this tutorial we will learn how to use Pandas sample to randomly select rows and columns ...

  7. java rmi 使用管道_使用Java RMI时要记住的两件事

    java rmi 使用管道 这是一篇简短的博客文章,介绍使用Java RMI时应注意的两个常见陷阱. 设置java.rmi.server.hostname 如果您感到陌生,Connection拒绝托管 ...

  8. 多线程面试题_线程魔术技巧:使用Java线程可以做的5件事

    多线程面试题 Java线程最鲜为人知的事实和用例是什么? 有些人喜欢爬山,有些人喜欢跳伞. 我,我喜欢Java. 我喜欢它的一件事是,您永不停止学习. 您每天使用的工具通常可以为您带来全新的面貌,以及 ...

  9. 宝塔如何备份网站_学习织梦网站必需会的一件事:织梦网站数据备份

    任务:宝塔面板织梦网站备份 织梦CMS程序运行环境:PHP+MySQL 所以无论是备份还是还原,都涉及2个部分,一个是web文件的备份,一个是数据库的备份. 做好数据备份是站长管理员和维护人员的基本操 ...

  10. hibernate sql 执行两次_使用 Hibernate 和 MySQL 需要知道的五件事

    使用 JPA 和 Hibernate 的好处之一是它提供了数据库特定方言和功能抽象. 因此,理论上,您可以实现一个应用程序,将其连接到一个受支持的数据库,并且它可以在不用更改任何代码的情况下运行. H ...

最新文章

  1. Redis-04Redis数据结构--哈希hash
  2. 成功解决Ubuntu下的include/darknet.h:14:14: fatal error: cuda_runtime.h: No such file or directory
  3. hdu 2448 Mining Station on the Sea(最短路+费用流)
  4. string contains不区分大小写_String基础复习
  5. Online Judge System
  6. 关于cell中添加子视图 复用重叠问题的解决方法
  7. Angualr 加载速度慢,为页面初始化完成前添加loading
  8. 使用反射获取类的静态属性值
  9. ISO14000环境管理体系认证
  10. 真正靠谱免费的数据恢复软件哪个好用?
  11. newsgroup_txt
  12. Ubuntu关机(shut down)(power off)后不断电的问题
  13. 自动驾驶的疑点重重, 再次印证了科技的「非理性繁荣」
  14. 【Web前端大作业实例网页代码】html+css新闻资讯网页带dw模板和登陆注册(9页)
  15. matlab2016自带ga,[转载]MATLAB中自带遗传算法函数GA的用法
  16. Python PDF转JPG
  17. android 恢复出厂设置 代码,android恢复出厂设置以及系统升级流程
  18. 虚拟机服务器 资料安全,绝密:三步教你轻松窃取VMware虚拟机及其数据漏洞预警 -电脑资料...
  19. px、pt、dpi、dip、分辨率、屏幕尺寸等等概念
  20. 自动化测试框架如果都总结成这样,人人都能学好

热门文章

  1. centos漏洞系列(三):Google Android libnl权限提升漏洞
  2. 计算机系统集成工作总结,系统集成工作总结报告.docx
  3. 中国移动ZN-M160G光猫超级密码破解 | 河南移动兆能光猫超管密码获取 | 中国移动光猫如何开启UPnP功能
  4. git版本管理软件——git储藏
  5. 爬虫第3课 -豆瓣TOP250电影爬取
  6. 「保姆级教学」带你闹清楚JAVA人的TOM猫是啥,再整明白Mac下怎么安装Tomcat
  7. MySQL 教程(三)函数
  8. 基于JAVA城市湖泊信息管理系统计算机毕业设计源码+系统+lw文档+部署
  9. 小白常用的Widows10实用功能,让你更好掌控你的电脑。
  10. 4.widows对象