熊猫tv新功能介绍

Pandas is a powerful package for data scientists. There are many reasons we use Pandas, e.g. Data wrangling, Data cleaning, and Data manipulation. Although, there is a method that rarely talks about regarding Pandas package and that is the Data plotting.

Pandas是数据科学家的强大工具包。 我们使用Pandas的原因很多,例如数据整理,数据清理和数据操作。 虽然,有一种方法很少谈论有关Pandas软件包的问题,​​那就是Data plotting

Data plotting, just like the name implies, is a process to plot the data into some graph or chart to visualise the data. While we have much fancier visualisation package out there, some method is just available in the pandas plotting API.

顾名思义,数据绘制是将数据绘制到某些图形或图表中以可视化数据的过程。 虽然我们有很多更好的可视化程序包,但熊猫绘图API中仅提供了一些方法。

Let’s see a few selected method I choose.

让我们看看我选择的一些选定方法。

1.拉德维兹 (1. radviz)

RadViz is a method to visualise N-dimensional data set into a 2D plot. The problem where we have more than 3-dimensional (features) data or more is that we could not visualise it, but RadViz allows it to happen.

RadViz是一种将N维数据集可视化为2D图的方法。 我们拥有超过3维(特征)数据或更多数据的问题是我们无法可视化它,但是RadViz允许它发生。

According to Pandas, radviz allows us to project an N-dimensional data set into a 2D space where the influence of each dimension can be interpreted as a balance between the importance of all dimensions. In a simpler term, it means we could project a multi-dimensional data into a 2D space in a primitive way.

根据Pandas的说法,radviz允许我们将N维数据集投影到2D空间中,其中每个维的影响可以解释为所有维的重要性之间的平衡。 简单来说,这意味着我们可以以原始方式将多维数据投影到2D空间中

Let’s try to use the function in a sample dataset.

让我们尝试在样本数据集中使用该函数。

#RadViz exampleimport pandas as pdimport seaborn as sns#To use the pd.plotting.radviz, you need a multidimensional data set with all numerical columns but one as the class column (should be categorical).mpg = sns.load_dataset('mpg')pd.plotting.radviz(mpg.drop(['name'], axis =1), 'origin')
RadViz Result
RadViz结果

Above is the result of RadViz function, but how you would interpret the plot?

上面是RadViz函数的结果,但是如何解释该图呢?

So, each Series in the DataFrame is represented as an evenly distributed slice on a circle. Just look at the example above, there is a circle with the series name.

因此,DataFrame中的每个Series均表示为圆上均匀分布的切片。 只要看一下上面的例子,就会有一个带有系列名称的圆圈。

Each data point then is plotted in the circle according to the value on each Series. Highly correlated Series in the DataFrame are placed closer on the unit circle. In the example, we could see the japan and europe car data are closer to the model_year while the usa car is closer to the displacement. It means japan and europe car are most likely correlated to the model_year while usa car is with the displacement.

然后,根据每个系列的值将每个数据点绘制在圆圈中。 DataFrame中高度相关的Series位于单位圆上。 在示例中,我们可以看到日本和欧洲的汽车数据更接近model_year,而美国汽车的数据更接近排量。 这意味着日本和欧洲的汽车最有可能与model_year相关,而美国汽车则与排量相关。

If you want to know more about RadViz, you could check the paper here.

如果您想了解有关RadViz的更多信息,可以在此处查看该论文。

2. bootstrap_plot (2. bootstrap_plot)

According to Pandas, the bootstrap plot is used to estimate the uncertainty of a statistic by relying on random sampling with replacement. In simpler words, it is used to trying to determine the uncertainty in fundamental statistic such as mean and median by resampling the data with replacement (you could sample the same data multiple times). You could read more about bootstrap here.

根据Pandas的说法, 引导程序图依赖于随机抽样和替换来估计统计的不确定性。 用简单的话来说, 它用于尝试通过替换对数据进行重采样来确定基本统计数据的不确定性,例如均值和中位数 (您可以多次采样同一数据)。 您可以在此处阅读有关引导的更多信息。

The boostrap_plot function will generate bootstrapping plots for mean, median and mid-range statistics for the given number of samples of the given size. Let’s try using the function with an example dataset.

boostrap_plot函数将为给定大小的给定数量的样本生成均值,中值和中间范围统计量的自举图。 让我们尝试将函数与示例数据集一起使用。

For example, I have the mpg dataset and already have the information regarding the mpg feature data.

例如,我有mpg数据集,并且已经有了有关mpg特征数据的信息。

mpg['mpg'].describe()

We could see that the mpg mean is 23.51 and the median is 23. Although this is just a snapshot of the real-world data. How are the values actually is in the population is unknown, that is why we could measure the uncertainty with the bootstrap methods.

我们可以看到mpg平均值为23.51,中位数为23。尽管这只是真实数据的快照。 实际值如何在总体中是未知的,这就是为什么我们可以使用自举法来测量不确定性的原因。

#bootstrap_plot examplepd.plotting.bootstrap_plot(mpg['mpg'],size = 50 , samples = 500)

Above is the result example of bootstap_plot function. Mind that the result could be different than the example because it relies on random resampling.

上面是bootstap_plot函数的结果示例。 请注意,结果可能与示例不同,因为它依赖于随机重采样。

We could see in the first set of the plots (first row) is the sampling result, where the x-axis is the repetition, and the y-axis is the statistic. In the second set is the statistic distribution plot (Mean, Median and Midrange).

我们可以在第一组图(第一行)中看到采样结果,其中x轴是重复项,y轴是统计量。 第二组是统计分布图(均值,中位数和中位数)。

Take an example of the mean, most of the result is around 23, but it could be between 22.5 and 25 (more or less). This set the uncertainty in the real world that the mean in the population could be between 22.5 and 25. Note that there is a way to estimate the uncertainty by taking the values in the position 2.5% and 97.5% quantile (95% confident) although it is still up to your judgement.

以平均值为例,大多数结果在23左右,但可能在22.5到25之间(或多或少)。 这设置了现实世界中的不确定性,即总体平均值可能在22.5和25之间。请注意,尽管有2.5%和97.5%的分位数(95%的置信度),但是有一种方法可以估计不确定性这仍然取决于您的判断。

3. lag_plot (3. lag_plot)

A lag plot is a scatter plot for a time series and the same data lagged. Lag itself is a fixed amount of passing time; for example, lag 1 is a day 1 (Y1) with a 1-day time lag (Y1+1 or Y2).

滞后图是时间序列的散点图,并且相同数据滞后。 滞后本身是固定的通过时间; 例如,滞后1是第1天(Y1),时滞为1天(Y1 + 1或Y2)。

A lag plot is used to checks whether the time series data is random or not, and if the data is correlated with themselves. Random data should not have any identifiable patterns, such as linear. Although, why we bother with randomness or correlation? This is because many Time Series models are based on the linear regression, and one assumption is no correlation (Specifically is no Autocorrelation).

滞后图用于检查时间序列数据是否随机,以及数据是否与自身相关。 随机数据不应具有任何可识别的模式,例如线性。 虽然,为什么我们要扰乱随机性或相关性? 这是因为许多时间序列模型都基于线性回归,并且一个假设是不相关的(特别是没有自相关)。

Let’s try with an example data. In this case, I would use a specific package to scrap stock data from Yahoo Finance called yahoo_historical.

让我们尝试一个示例数据。 在这种情况下,我将使用一个名为yahoo_historical的特定程序包从Yahoo Finance抓取股票数据。

pip install yahoo_historical

With this package, we could scrap a specific stock data history. Let’s try it.

有了这个软件包,我们可以抓取特定的库存数据历史记录。 让我们尝试一下。

from yahoo_historical import Fetcher#We would scrap the Apple stock data. I would take the data between 1 January 2007 to 1 January 2017 data = Fetcher("AAPL", [2007,1,1], [2017,1,1])apple_df = data.getHistorical()#Set the date as the indexapple_df['Date'] = pd.to_datetime(apple_df['Date'])apple_df = apple_df.set_index('Date')

Above is our Apple stock dataset with the date as the index. We could try to plot the data to see the pattern over time with a simple method.

上面是我们的Apple股票数据集,其中以日期为索引。 我们可以尝试使用一种简单的方法来绘制数据以查看随时间变化的模式。

apple_df['Adj Close'].plot()

We can see the Adj Close is increasing over time but is the data itself shown any pattern in with their lag? In this case, we would use the lag_plot.

我们可以看到,随着时间的推移,“关闭收盘价”(Adj Close)不断增加,但是数据本身是否显示出任何与滞后有关的模式? 在这种情况下,我们将使用lag_plot。

#Try lag 1 daypd.plotting.lag_plot(apple_df['Adj Close'], lag = 1)

As we can see in the plot above, it is almost near linear. It means there is a correlation between daily Adj Close. It is expected as the daily price of the stock would not be varied much in each day.

如上图所示,它几乎接近线性。 这意味着每日调整关闭之间存在相关性。 可以预期,因为股票的每日价格每天不会有太大变化。

How about a weekly basis? Let’s try to plot it

每周一次如何? 让我们尝试绘制它

#The data only consist of work days, so one week is 5 dayspd.plotting.lag_plot(apple_df['Adj Close'], lag = 5)

We can see the pattern is similar to the lag 1 plot. How about 365 days? would it have any differences?

我们可以看到该模式类似于滞后1图。 365天怎么样? 有什么区别吗?

pd.plotting.lag_plot(apple_df['Adj Close'], lag = 365)

We can see right now the pattern becomes more random, although the non-linear pattern still exists.

现在我们可以看到模式变得更加随机,尽管非线性模式仍然存在。

4. scatter_matrix (4. scatter_matrix)

The scatter_matrix is just like the name implies; it creates a matrix of scatter plot. Let’s try it with an example at once.

顾名思义, scatter_matrix就是一样。 它创建了散点图矩阵。 让我们立即尝试一个示例。

import matplotlib.pyplot as plttips = sns.load_dataset('tips')pd.plotting.scatter_matrix(tips, figsize = (8,8))plt.show()

We can see the scatter_matrix function automatically detects the numerical features within the Data Frame we passed to the function and create a matrix of the scatter plot.

我们可以看到scatter_matrix函数自动检测我们传递给该函数的数据框内的数字特征,并创建散点图的矩阵。

In the example above, between two numerical features are plotted together to create a scatter plot (total_bill and size, total_bill and tip, and tip and size). Whereas, the diagonal part is the histogram of the numerical features.

在上面的示例中,两个数字特征之间被绘制在一起以创建散点图(total_bill和size,total_bill和tip,以及tip和size)。 而对角线部分是数值特征的直方图。

This is a simple function but powerful enough as we could get much information with a single line of code.

这是一个简单的功能,但功能足够强大,因为我们可以用一行代码来获取很多信息。

结论 (Conclusion)

Here I have shown you 4 different pandas plotting functions that you should know, that includes:

在这里,我向您展示了您应该了解的4种不同的熊猫绘图功能,其中包括:

  1. radviz拉德维兹
  2. bootstrap_plotbootstrap_plot
  3. lag_plotlag_plot
  4. scatter_matrixscatter_matrix

I hope it helps!

希望对您有所帮助!

翻译自: https://towardsdatascience.com/4-pandas-plotting-function-you-should-know-5a788d848963

熊猫tv新功能介绍


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

相关文章:

  • vs显示堆栈数据分析_什么是“数据分析堆栈”?
  • 广告投手_测量投手隐藏自己的音高的程度
  • python bokeh_提升视觉效果:使用Python和Bokeh制作交互式地图
  • nosql_探索NoSQL系列
  • python中api_通过Python中的API查找相关的工作技能
  • 欺诈行为识别_使用R(编程)识别欺诈性的招聘广告
  • nlp gpt论文_GPT-3:NLP镇的最新动态
  • 基于plotly数据可视化_[Plotly + Datashader]可视化大型地理空间数据集
  • 划痕实验 迁移面积自动统计_从Jupyter迁移到合作实验室
  • 数据开放 数据集_除开放式清洗之外:叙述是开放数据门户的未来吗?
  • 它们是什么以及为什么我们不需要它们
  • 机器学习 啤酒数据集_啤酒数据集上的神经网络
  • nasa数据库cm1数据集_获取下一个地理项目的NASA数据
  • r语言处理数据集编码_在强调编码语言或工具之前,请学习这3个基本数据概念
  • 数据迁移测试_自动化数据迁移测试
  • 使用TensorFlow概率预测航空乘客人数
  • 程序员 sql面试_非程序员SQL使用指南
  • r a/b 测试_R中的A / B测试
  • 工作10年厌倦写代码_厌倦了数据质量讨论?
  • 最佳子集aic选择_AutoML的起源:最佳子集选择
  • 管道过滤模式 大数据_大数据管道配方
  • 用户体验可视化指南pdf_R中增强可视化的初学者指南
  • sql横着连接起来sql_SQL联接的简要介绍(到目前为止)
  • 如何击败Python的问题
  • 数据冒险控制冒险_劳动生产率和其他冒险
  • knn 邻居数量k的选取_选择K个最近的邻居
  • 什么样的代码是好代码_什么是好代码?
  • 在Python中使用Twitter Rest API批量搜索和下载推文
  • 大数据 vr csdn_VR中的数据可视化如何革命化科学
  • 导入数据库怎么导入_导入必要的库

熊猫tv新功能介绍_您应该知道的4种熊猫绘图功能相关推荐

  1. 谷歌表格_您应该知道的5种Google表格功能

    谷歌表格 You're probably familiar with the basics of Google Sheets, but Google's spreadsheet offering bo ...

  2. ftpclient怎么获取到该目录下面得文件_你应该知道的10种Python文件系统方法

    使用os和shutil操作文件和文件夹 你可以编写Python程序来与文件系统进行交互来做很酷的事情.怎么做并不总是非常清楚.本文是当前和有抱负的开发人员和数据科学家的指南.我们将重点介绍10个基本的 ...

  3. 查询分析器在哪里_你应该知道的3种Node.js分析器类型

    Node.js类似于许多其他编码语言,因为它需要与正确的工具结合使用来调试程序,克服任何瓶颈并优化其功能.使用正确的分析器,您可以毫不费力地实现这一目标,尽管它们都不是完美的. 在编码中,分析器是一种 ...

  4. 雷达和激光雷达_您应该知道的6种雷达下JavaScript工具

    雷达和激光雷达 JS Foundation是著名的开源JavaScript项目的所在地,其中最著名的是流行的jQuery JavaScript库. 但是,对于云供应,物联网(IoT),支付和Node. ...

  5. 熊猫tv新功能介绍_熊猫简单介绍

    熊猫tv新功能介绍 Out of all technologies that is introduced in Data Analysis, Pandas is one of the most pop ...

  6. 电脑键盘功能介绍_远程操控软件介绍

    介绍几款好用的远程控制软件,轻松远程办公,为他人解决电脑问题! 我们都知道windows系统自带远程桌面连接,但其连接同一个局域网的电脑还好,如果是连接外网的相对有些麻烦,而且就算是连接内网的被连接的 ...

  7. 在钉钉上怎么手写_钉钉直播上课可以写字吗_钉钉直播写字板功能介绍_玩游戏网...

    钉钉直播上课已经有很多学校在使用了,这个时候就有人问了,能不能在钉钉上用手写字,在学习资料上做笔记,目前发下来钉钉的很多功能,不过关于写字这个功能暂且还没有,那么想要用写字的方式教学要怎么做呢?这就让 ...

  8. git分支指的是_你一定知道的Git分支模型

    原标题:你一定知道的Git分支模型 写在前面 本文不是一篇Git入门指南,也不是 Git命令行使用技巧的讲解,而是谈谈作者在过往工作中使用的几种代码版本管理工具的一些体会,同时重点讲解一下Git的分支 ...

  9. Java开发人员应该知道的5大Spring Boot功能

    您可能已经听说过Spring Boot,这是用不到140个字符创建一个Spring Web应用程序的神奇力量,可以在一条推文中编写这些字符,但这到底意味着什么? 哪些功能可以使Spring Boot具 ...

最新文章

  1. php各种编码集详解和在什么情况下进行使用 [php 字符集 显示]
  2. 【Vue】component学习笔记
  3. LFFD ncnn torch
  4. JAVA学习篇--Servlet详解
  5. xil_printf打印遇到的问题
  6. 微信小程序开发需要了解的三个内核技术
  7. 连接mysql数据库小知识记录
  8. 随谈---------多年之后,我又回来了
  9. Ajax 登录控件(三)
  10. matlab中rand函数用法
  11. 雷达原理---基础知识
  12. DEMAC电机驱动型电缆卷筒—上海班品智能
  13. GitHub建立个人网站(一)
  14. 对于人工智能的认识,我们需要更深入全面的理解
  15. 群论:群的定义与阿贝尔群
  16. 0905系统及数据库
  17. Unity导入模型和材质丢失问题处理(大批量操作)
  18. 【codecs】视频显示分辨率格式分析
  19. Microsoft visio 2010之简单使用
  20. 【欧拉计划第 5 题】最小公倍数 Smallest multiple

热门文章

  1. 计算矩阵的逆和行列式的值(高斯消元+LU分解)
  2. Linux C++ 回射服务器
  3. C语言实现的简单的线程池
  4. Linux下基于socket和多线程的聊天室小程序
  5. gdb调试多进程程序
  6. 在linux下利用ls命令进行模糊查找
  7. static in c language
  8. 三级嵌入式选择知识点整理
  9. 《Python》进程收尾线程初识
  10. 白鹭引擎 - 显示对象的基准点与横纵坐标 ( 绘制一个来回移动的绿色方块 )