导入数据分析三剑客
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
apple=pd.read_csv("C://Users/Administrator/Desktop/apple.csv")
#a=apple.dtypes
'''
Date object
Open float64
High float64
Low float64
Close float64
Adj Close float64
Volume int64
dtype: object'''
#a=apple.head()
'''
Date Open High Low Close Adj Close Volume
0 1999-03-01 1.243304 1.243304 1.200893 1.205357 1.051931 121956800
1 1999-03-02 1.218750 1.261161 1.205357 1.236607 1.079204 170763600
2 1999-03-03 1.241071 1.254464 1.196429 1.220982 1.065567 73337600
3 1999-03-04 1.232143 1.232143 1.156250 1.194196 1.042192 91817600
4 1999-03-05 1.225446 1.225446 1.156250 1.185268 1.034399 117009200
'''
apple['Date']=pd.to_datetime(apple['Date'])#pd.to_datetime()将object类型数据转换为时间类型数据,int。有利于排序
#a=apple.dtypes
'''
Date datetime64[ns]
Open float64
High float64
Low float64
Close float64
Adj Close float64
Volume int64
dtype: object
'''
#将Date设置为行索引
apple.set_index('Date',inplace=True)
#a=apple.head()
'''
Open High Low Close Adj Close Volume
Date
1999-03-01 1.243304 1.243304 1.200893 1.205357 1.051931 121956800
1999-03-02 1.218750 1.261161 1.205357 1.236607 1.079204 170763600
1999-03-03 1.241071 1.254464 1.196429 1.220982 1.065567 73337600
1999-03-04 1.232143 1.232143 1.156250 1.194196 1.042192 91817600
1999-03-05 1.225446 1.225446 1.156250 1.185268 1.034399 117009200
'''
plt.plot(apple['Adj Close'])
plt.show()
结果展示