七、Pandas—— Plot 画图

 

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# plot的方法
# plot 折线图, bar 条形图,hist, box, kde, area ,
# scatter 散点图, hexbin, pie
print("***************Series*******************")
#
s = pd.Series(np.random.randn(1000),index=np.arange(1000))
s = s.cumsum()# 累加
# s.plot()
# plt.show()
print("***************DataFrame*******************")
df = pd.DataFrame(np.random.randn(1000, 4),
                  index=np.arange(1000),
                  columns=list("ABCD"))
print(df.head(3))
#           A         B         C         D
# 0  0.047637  0.817707  0.140914  1.455110
# 1  1.097064 -1.334110  0.516589 -1.541100
# 2  0.218156 -0.976214 -0.726948  0.193543
print("===========plot===========")
# 列上每个数值进行累加
df = df.cumsum()
print(df.head(3))
#           A         B         C         D
# 0  0.047637  0.817707  0.140914  1.455110
# 1  1.144701 -0.516403  0.657503 -0.085990
# 2  1.362857 -1.492617 -0.069445  0.107552

# df.plot() # 可以设置很多参数
# plt.show()
print("===========scatter 散点图===========")
#
ax = df.plot.scatter(x='A', y='B', color='DarkBlue', label='Class 1')
# 指定 ax 参数, 在一张图上打印两组数据
df.plot.scatter(x='A', y='C', color='DarkGreen', label='Class 2', ax=ax)
plt.show()

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值