天天看點

pandas小節 pandas繪圖

import numpy as np
import pandas as pd
import	pandas_datareader.data	as	web
import matplotlib.pyplot as plt
           
all_data = {ticker:web.get_data_yahoo(ticker) for ticker in	['AAPL', 'IBM',	'MSFT',	'GOOG']}
price = pd.DataFrame({ticker:	data['Adj Close'] for ticker, data in all_data.items()})
volume	= pd.DataFrame({ticker:data['Volume'] for ticker, data in all_data.items()})
returns	= price.pct_change()
returns.tail()
           
AAPL IBM MSFT GOOG
Date
2020-06-08 0.005912 0.027942 0.006197 0.005715
2020-06-09 0.031578 -0.028582 0.007645 0.006602
2020-06-10 0.025728 -0.015166 0.037092 0.006654
2020-06-11 -0.048010 -0.091322 -0.053698 -0.042303
2020-06-12 0.008634 0.033048 0.007892 0.006653
import	seaborn	as	sns
           
obj= np.random.normal(0,1,size=100)
obj2 = np.random.normal(10,2,size=100)
           
<matplotlib.axes._subplots.AxesSubplot at 0x236f2f88908>
           
pandas小節 pandas繪圖
<matplotlib.axes._subplots.AxesSubplot at 0x236ec07c5c0>
           
pandas小節 pandas繪圖
<matplotlib.axes._subplots.AxesSubplot at 0x236f11105f8>
           
pandas小節 pandas繪圖
sns.regplot('AAPL',	'IBM',	data=price)
plt.title('Changes in log %s versus log %s' % ('AAPL','IBM'))
           
Text(0.5, 1.0, 'Changes in log AAPL versus log IBM')
           
pandas小節 pandas繪圖