数据分析绘图练习(散点)

使用000001.csv数据计算最高价和开盘价之差diff,绘制前后两天diff的散点图,研究是否具有相关性。

1. 导入相关包

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

2. 读取文件

data=pd.read_csv("000001.csv")

3. 求最高价与开盘价的差

data["cha"]=data.High-data.Open

4. 去除无用数据

data.drop(["Open","High","Low","Close","Turnover","Volume","cha"],axis=1,inplace=True)

5. 计算差值的diff

data["cha_diff"]=data.cha.diff()

6. 绘制散点图寻找关系

plt.scatter(data.Date,data.cha_diff,alpha=0.5)
plt.show()

Figure_1.png