【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 天前
基于scrapy的网易云音乐数据采集与分析设计实现
python·信息可视化·数据分析·beautifulsoup·numpy·pandas
测试摆渡媛2 天前
Excel模板填充工具(工具&脚本分享)
python·数据挖掘·pandas
_Soy_Milk2 天前
【算法工程师】—— Python 数据分析
python·数据分析·numpy·pandas·matplotlib
Data-Miner3 天前
类似Pandas AI的几个数据分析处理智能体介绍
人工智能·数据分析·pandas
智航GIS5 天前
11.18 自定义Pandas扩展开发指南:打造你的专属数据分析武器库
python·数据分析·pandas
人工干智能6 天前
你知道 Pandas 中 `pd.get_dummies()` 会生成哪些独热的新列么?
大数据·pandas
weixin_462446236 天前
Python 实战:将 HTML 表格一键导出为 Excel(xlsx)
linux·python·excel·pandas
2401_841495646 天前
【Python高级编程】学习通签到统计工具
python·pandas·gui·tkinter·pyinstaller·数据统计·exe程序
西红市杰出青年7 天前
Python异步----------await方法逻辑
pandas
ID_180079054738 天前
日本乐天商品详情API接口的请求构造与参数说明
开发语言·python·pandas