熊猫tv新功能介绍
Pandas is a great tool for managing and importing your data. And with this easy and small tutorial, I will go take you through some of the important and fast functions to plot your data with out the need to use matplotlib.
P andas是用于管理和导入数据的出色工具。 在这个简单易用的教程中,我将带您通过一些重要而又快速的函数来绘制数据,而无需使用matplotlib。
Let’s get started.
让我们开始吧。
使用熊猫导入数据: (Import data using pandas:)
First, we need to import the CSV
file which we’ll apply the functions on.
首先,我们需要导入CSV
文件,并将其应用到功能上。
data = pd.read_csv('df3')data.head()
This is how the data file look like:
数据文件如下所示:
![Image for post](https://i-blog.csdnimg.cn/blog_migrate/e02bdbd260a3a5de82ec6716b2b1336d.png)
Now, let’s see what plots can we apply on our data.
现在,让我们看看可以将哪些图应用于数据。
1.直方图: (1. Histogram:)
Plot the frequency of data. Frequency means how many times a range of values appeared. We can define the range by something called bins, it’s how many divisions we’ll split the data to.
绘制数据频率。 频率表示一个值范围出现多少次。 我们可以通过称为bin的方式定义范围,这是将数据划分为多少个分区。
For example if we want to plot the histogram for column ‘a’, we run this line and set the bins for 20.
例如,如果要绘制列“ a”的直方图,则运行此行并将bin设置为20。
data['a'].plot.hist(bins=20)
![Image for post](https://i-blog.csdnimg.cn/blog_migrate/6ef97fdff95bc2ea980b1bfd94505b72.png)
2.分散:(2. Scatter:)
Scatter here represents the data values in form of dots with respect to two different numeric variables.
此处的散点图表示相对于两个不同数字变量的点形式的数据值。
We do that by running this line:
我们通过运行以下行来做到这一点:
data.plot.scatter(x='A',y='B')
![Image for post](https://i-blog.csdnimg.cn/blog_migrate/d22825fea8e0246bbbb45b0f71b44517.png)
3.酒吧:(3. Bar:)
Each Bar represents the category and its value on the y-axis.
每个条形图代表类别及其在y轴上的值。
data.plot.bar()
![Image for post](https://i-blog.csdnimg.cn/blog_migrate/df281a3c2c8875aa7c42b8643905a939.png)
结论(Conclusion)
These are the most important and used functions for plotting with pandas. If you want more of this you can find at this link. I hope this article is useful.
这些是绘制熊猫最重要和最常用的功能。 如果您想要更多这些,可以在此链接中找到。 希望本文对您有所帮助。
Thank you.
谢谢。
翻译自: https://medium.com/swlh/pandas-builtin-visualization-functions-529e452f805a
熊猫tv新功能介绍