Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
%matplotlib inline
import pandas as pd
import matplotlib.pyplot as plt
url="http://www.twse.com.tw/indicesReport/MI_5MINS_HIST?response=csv&date=20170101"
stocks = pd.read_csv(url, encoding='big5', skiprows=1, thousands=',')
stocks = stocks.drop(stocks.columns[5], axis=1)
stocks.columns = ['Date', 'Open', 'High', 'Low', 'Close']
stocks = stocks.set_index('Date')
for i in range(2,13):
url="http://www.twse.com.tw/indicesReport/MI_5MINS_HIST?response=csv&date=2017{:02}01".format(i)
stock = pd.read_csv(url, encoding='big5', skiprows=1, thousands=',')
stock = stock.drop(stock.columns[5], axis=1)
stock.columns = ['Date', 'Open', 'High', 'Low', 'Close']
stock = stock.set_index('Date')
stocks = pd.concat([stocks,stock])
stocks.plot()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.