点击查看代码
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
data = pd.DataFrame(data = np.random.randint(0,100,size=(8,4)),columns=['A','B','C','D'])
#查看数据基本描述
data.describe()

点击查看代码
data.sum()
data.mean()
data.var()
data.corr()
data.cov()
#偏度
data.skew()
data.kurt()#峰度
data.cumsum()





点击查看代码
data.rolling(2).sum()
# %%
data.cumprod()
# %%
data.cummax()
# %%
data.cummin()
# %%
data.rolling(2).mean()
# %%
print(data.rolling(8).std())
print(data.std())







点击查看代码
# %%
#正弦曲线图
x = np.linspace(0,2*np.pi,50)
y = np.sin(x)
plt.plot(x,y,'g--')
plt.show()

点击查看代码
#饼图
labels = ['A','B','C','D']
sizes = [30,40,25,5]
colors = ['yellowgreen','gold','lightskyblue','lightcoral']
explode = (0.2,0.1,0,0)
plt.pie(sizes,explode=explode,labels=labels,colors=colors,autopct='%1.1f%%',shadow=True,startangle=90)
plt.axis('equal')#显示为圆
plt.show()

点击查看代码
#直方图
x = np.random.randn(1000)#一千个服从正态分布的随机数
plt.hist(x,10)#十组
plt.show()

点击查看代码
#箱型图
x = np.random.randn(1000)
data = pd.DataFrame([x,x+1]).T#构造两列的DataFrame
data.plot(kind='box')
plt.show()

点击查看代码
#箱型图
x = np.random.randn(1000)
data = pd.DataFrame([x,x+1]).T#构造两列的DataFrame
data.boxplot()

点击查看代码
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
x = pd.Series(np.exp(np.arange(20)))
plt.figure(figsize = (8, 9)) # 设置画布大小
ax1 = plt.subplot(2, 1, 1)
x.plot(label = '原始数据图', legend = True)
ax1 = plt.subplot(2, 1, 2)
x.plot(logy = True, label = '对数数据图', legend = True)
plt.show()

点击查看代码
error = np.random.randn(10) # 定义误差列
y = pd.Series(np.sin(np.arange(10))) # 均值数据列
y.plot(yerr = error) # 绘制误差图
plt.show()
