This time I will use pandas. First, prepare the csv data as a preparation. This time, we will take the Nikkei 225 as an example.
#csv data example(part)
Data date,closing price,Open price,High price,Low price
2017/01/04,19594.16,19298.68,19594.16,19277.93
2017/01/05,19520.69,19602.10,19615.40,19473.28
2017/01/06,19454.33,19393.55,19472.37,19354.44
Let's run it in Python. First run the following code.
import pandas as pd
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn import datasets
plt.style.use('ggplot') #A magic trick to display the figure neatly
font = {'family' : 'meiryo'}
Next, read the csv data and see what the data looks like with .head (). ) Here, the part of parse_dates is inserted to make the type of "data date" datetime.
nikkei = pd.read_csv("nikkei.csv", parse_dates=['Data date']) #Read csv data
nikkei.head() #Take a look at the overview
Let's check the data type.
type(nikkei["Data date"][0])
It's Timestamp. Next, let's look at columns.
nikkei.columns
I will post the output so far.
Finally, let's take a look at the figure. When I run the following code ...
plt.figure(figsize=(10, 8))
plt.plot(nikkei['Data date'], nikkei['closing price'], label='test')
plt.xticks(fontsize=8)
plt.yticks(fontsize=22)
plt.xlabel("Date")
plt.ylabel("nikkei_heikin")
It turned out to be something like this. This time is over. Improvements will be discussed in a later article.
Recommended Posts