【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') # 指定横坐标与纵坐标,生成一个散点图
相关推荐
lkx097882 天前
01-数据分析入门-Pandas实战
数据挖掘·数据分析·pandas
淼澄研学4 天前
Python自动化办公实操:基于pandas与requests的5个提效场景解析
python·自动化·pandas
Y38153266210 天前
serpbase + Pandas + Jupyter 数据分析实战
jupyter·数据分析·pandas
元Y亨H10 天前
numpy与pandas 的介绍
numpy·pandas
小大宇11 天前
python pandas dataFrame sqlAlchemy案例
python·pandas
chouchuang12 天前
day-040-Pandas可视化与实战
pandas
chouchuang15 天前
day-037-Pandas数据读取
pandas
benchmark_cc17 天前
如何用 Python 进行多周期 K 线合成与时区对齐?基于 QuantDash 与 Pandas 的量化数据清洗实战(附 GitHub 源码)
开发语言·python·github·盯盘·pandas·quantdash·量化数据
梅雅达编程笔记18 天前
零基础学 Python 第14章 | 模块、包与第三方库
开发语言·python·django·numpy·pandas
梅雅达编程笔记18 天前
零基础学 Python 第15章 | 类与对象:面向对象编程入门
开发语言·python·django·numpy·pandas