【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') # 指定横坐标与纵坐标,生成一个散点图
相关推荐
编程乐学1 天前
网络资源模板--基于Android Studio 实现的画板App
android·android studio·画图·移动端开发·画板·安卓大作业
修钩.5 天前
力扣 Pandas 挑战(5)---数据分组
算法·leetcode·pandas
万粉变现经纪人5 天前
如何解决pip安装报错ModuleNotFoundError: No module named ‘plotly’问题
python·scrapy·plotly·pycharm·flask·pandas·pip
码界奇点6 天前
Python深度挖掘:openpyxl与pandas高效数据处理实战指南
开发语言·数据库·python·自动化·pandas·python3.11
码界筑梦坊6 天前
91-基于Spark的空气质量数据分析可视化系统
大数据·python·数据分析·spark·django·numpy·pandas
蔷薇のぬ6 天前
Python 使用pandas库实现Excel字典码表对照自动化处理
python·pandas
宝山哥哥6 天前
python办自动化--利用vba或者python按需求读取excel文件指定列,更改列名后,按照要求将列排序,最后填充空白单元格
python·数据分析·自动化·excel·pandas
秋难降8 天前
一篇文章带你了解Pandassssssssssssssss
大数据·python·pandas
封奚泽优8 天前
使用Python绘制金融数据可视化工具
python·信息可视化·excel·pandas·pyplot·qtwidgets·qtcore
一百天成为python专家9 天前
K-近邻算法
数据结构·python·算法·pandas·近邻算法·ipython·python3.11