【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 天前
机器学习第一天(共12天)
人工智能·python·机器学习·conda·numpy·pandas·matplotlib
招风的黑耳2 天前
Axure动态柱状图设计指南:从静态到交互的完整实现
交互·axure·柱状图
星越华夏2 天前
Polars中导入excel文件
python·pandas
我材不敲代码4 天前
零基础快速上手 Pandas 数据处理
pandas
星越华夏4 天前
pandas中时间处理
pandas
Cloud_Shy6185 天前
Python 数据分析基础入门:《Excel Python:飞速搞定数据分析与处理》学习笔记系列(第十二章 用户定义函数 下篇)
python·plotly·数据分析·excel·numpy·pandas
云和数据.ChenGuang6 天前
基于鲲鹏 HPC 的 AI 对话机器人架构设计与技术实现
人工智能·数据分析·机器人·pandas·数据预处理·数据训练
Cloud_Shy6186 天前
Python 数据分析基础入门:《Excel Python:飞速搞定数据分析与处理》学习笔记系列(第十二章 用户定义函数 中篇)
python·数据分析·excel·pandas
沉下去,苦磨练!6 天前
python的数据分析Pandas
python·数据分析·pandas
毋语天7 天前
Pandas 数据处理进阶:缺失值、合并、分组聚合与透视表
python·数据分析·pandas·数据清洗·透视表