pandas 8 画图
from __future__ import print_function
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# plot data
Series 构造1列数据,data.plot()
# Series 构造1列数据
np.random.seed(1)
data = pd.Series(np.random.randn(1000), index=np.arange(1000)) # 生成随机数据,有正有负
data = data.cumsum() # 累加,列方向上
data.plot() # 根据数据画图
plt.show()

print(data.head())
> 0 1.624345
> 1 1.012589
> 2 0.484417
> 3 -0.588551
> 4 0.276856
> dtype: float64
DataFrame 构造4列数据,data.plot()
# DataFrame 构造4列数据
data = pd.DataFrame(np.random.randn(1000, 4), index=np.arange(1000), columns=list("ABCD"))
data = data.cumsum() # 累加,列方向上
data.plot()
plt.show()

print(data.head())
> A B C D
> 0 -0.153236 -2.432509 0.507984 -0.324032
> 1 -1.664313 -3.303931 -0.356846 0.284717
> 2 -1.102675 -1.789180 0.291079 -1.066933
> 3 -2.511884 -0.658455 1.857765 -1.304681
> 4 -1.953081 -2.163346 -0.086156 -2.478704
data.plot.scatter(x='A', y='C')
# plot methods:
# 'bar', 'hist', 'box', 'kde', 'area', scatter', hexbin', 'pie'
ax = data.plot.scatter(x='A', y='B', color='DarkBlue', label="Class 1")
data.plot.scatter(x='A', y='C', color='LightGreen', label='Class 2', ax=ax)
plt.show()

END
pandas 8 画图的更多相关文章
- python pandas 画图、显示中文、股票K线图
目录: 1.pandas官方画图链接 2.标记图中数据点 3.画图显示中文 4.画股票K线图 5.matplotlib基本用法 6.format输出 6.format输出例子 eps_range=[0 ...
- Python pandas快速入门
Python pandas快速入门2017年03月14日 17:17:52 青盏 阅读数:14292 标签: python numpy 数据分析 更多 个人分类: machine learning 来 ...
- Numpy and Pandas
安装 视频链接:https://morvanzhou.github.io/tutorials/data-manipulation/np-pd/ pip install numpy pip instal ...
- OnePy--构建属于自己的量化回测框架
本文主要记录我构建量化回测系统的学习历程. 被遗弃的项目:Chandlercjy/OnePy_Old 新更新中的项目:Chandlercjy/OnePy 目录 1. 那究竟应该学习哪种编程语言比较好呢 ...
- [数据可视化之一]Pandas单变量画图
Pandas单变量画图 Bar Chat Line Chart Area Chart Histogram df.plot.bar() df.plot.line() df.plot.area() df. ...
- 【转】Pandas学习笔记(七)plot画图
Pandas学习笔记系列: Pandas学习笔记(一)基本介绍 Pandas学习笔记(二)选择数据 Pandas学习笔记(三)修改&添加值 Pandas学习笔记(四)处理丢失值 Pandas学 ...
- 用豆瓣加速安装pandas、numpy、matplotlib(画图)
安装pandas.numpy会同时被安装 #pthony2.x,用豆瓣加速安装pandas pip install -i https://pypi.doubanio.com/simple/ panda ...
- Python | Pandas数据清洗与画图
准备数据 2016年北京PM2.5数据集 数据源说明:美国驻华使馆的空气质量检测数据 数据清洗 1. 导入包 import numpy as np import matplotlib.pyplot a ...
- Pandas高级教程之:plot画图详解
目录 简介 基础画图 其他图像 bar stacked bar barh Histograms box Area Scatter Hexagonal bin Pie 在画图中处理NaN数据 其他作图工 ...
随机推荐
- 路飞学城Python-Day33
1.简述计算机操作系统中的“中断”的作用? 为什么有中断? 现代操作系统一般都是采用基于时间片的优先级调度算法,把CPU的时间划分为很细粒度的时间片,一个任务每次只能时间这么多的时间,时间到了就必须交 ...
- 04 SqlServer
数据库的注释 –(两个横线) 主键表 外键表 主键,组合主键 SqlServer 使用附加 权限 主文件mdf 日志文件ldf 数据类型 char varchar nchar nvarchar cha ...
- FreeCodeCamp初级算法部分学习
Reverse a String 翻转字符串 先把字符串转化成数组,再借助数组的reverse方法翻转数组顺序,最后把数组转化成字符串. 你的结果必须得是一个字符串 当你完成不了挑战的时候,记得开大招 ...
- [luogu2607 ZJOI2008] 骑士 (树形dp)
题目描述 Z国的骑士团是一个很有势力的组织,帮会中汇聚了来自各地的精英.他们劫富济贫,惩恶扬善,受到社会各界的赞扬. 最近发生了一件可怕的事情,邪恶的Y国发动了一场针对Z国的侵略战争.战火绵延五百里, ...
- 当一个线程进入一个对象的一个synchronized方法后, 其它线程是否可进入此对象的其它方法?
分几种情况: 1.其他方法前是否加了synchronized关键字,如果没加,则能. 2.如果这个方法内部调用了wait,则可以进入其他synchronized方法. 3.如果其他个方法都加了sync ...
- poj3061 Subsequence ,尺取法
A sequence of N positive integers (10 < N < 100 000), each of them less than or equal 10000, a ...
- spring web mvc第一天
spring web mvc 感觉就是高大上啊!啥都是配置文件就能够了.所以第一步就是弄清楚配置文件使用和总体框架的流程! Spring web mvc最重要的当然是Controller,也就是首先 ...
- php利用msqli访问数据库并实现分页,
<?php require_once 'login.php'; $num_rec_per_page=2; // 每页显示数量 //mysql_connect('localhost','jim', ...
- js解析网络中的json数据
<?php echo <<<_END <html> <head> </head> <body> <div id=" ...
- Python一行代码获得IP地址
比较靠谱的方法, 通过构造UDP包获得本机IP地址 python -c "import socket;print([(s.connect(('8.8.8.8', 53)), s.gets ...