【Pandas 入门-5】Pandas 画图

Pandas 画图

除了结合 matplotlib 与 seaborn 画图外,Pandas 也有自己的画图函数plot,它的语法一般为:

DataFrame.plot(x=None,y=None, kind='line',subplots=False, title=None)
x 横坐标数据
y 纵坐标数据
kind 默认是线图,还可以是'bar','barh','box','pie','scatter','hist'等
subplots 是否将每一列数据分别生成一个子图
title 图形的标题
python 复制代码
import pandas as pd

df = pd.DataFrame({'statistics': [85, 68, 90], 'math': [82, 63, 88], 'English': [84, 90, 78]})
df

| | statistics | math | English |
| 0 | 85 | 82 | 84 |
| 1 | 68 | 63 | 90 |

2 90 88 78
python 复制代码
df.plot()

从上图可以看出,Pandas 的plot默认对每一列数据,画一个线图。

python 复制代码
df.plot(kind='bar', title='My picture') # 画出柱状图
python 复制代码
df.plot(kind='bar', subplots=True) # 对每一列数据非别生成一个子图
python 复制代码
df.plot(x='math', y='statistics', kind='scatter') # 指定横坐标与纵坐标,生成一个散点图
相关推荐
老哥不老2 天前
Python调用SQLite及pandas相关API详解
python·sqlite·pandas
Hello world.Joey3 天前
数据挖掘入门-二手车交易价格预测
人工智能·python·数据挖掘·数据分析·conda·pandas
liuweidong08023 天前
【Pandas】pandas DataFrame cumprod
pandas
wxl7812275 天前
基于flask+pandas+csv的报表实现
python·flask·pandas
chaodaibing5 天前
pandas读取pymysql和解析excel的一系列问题(版本不匹配)
excel·pandas
aiweker7 天前
python数据分析(九):Pandas 分类数据(Categorical Data)处理
python·数据分析·pandas
TravelLight927 天前
Python pandas 向excel追加数据,不覆盖之前的数据
python·excel·pandas
liuweidong08028 天前
【Pandas】pandas DataFrame abs
pandas
liuweidong08028 天前
【Pandas】pandas DataFrame ewm
pandas
kngines9 天前
【PostgreSQL数据分析实战:从数据清洗到可视化全流程】8.1 基础图表绘制(折线图/柱状图/散点图)
postgresql·信息可视化·数据分析·柱状图·散点图·pyplot·折线图\