前回、ピジョンの株価データをWEBスクレイピングで取り出した後の続き。
Seabornで可視化
import pandas as pd
from pandas import Series,DataFrame
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_style('whitegrid')
%matplotlib inline
In [41]:
df_pigion_recent250.describe()
Out[41]:
日付 始値 高値 安値 終値 出来高 売買代金
count 250 250 250 250 250 250 250
unique 250 194 204 209 211 245 250
top 2015-11-04 3500.00 3245.00 3715.00 3900.00 1451400 3711571500
freq 1 7 6 4 3 2 1
In [44]:
df_pigion_recent250.info()
<class 'pandas.core.frame.DataFrame'>
Int64Index: 250 entries, 0 to 249
Data columns (total 7 columns):
日付 250 non-null object
始値 250 non-null object
高値 250 non-null object
安値 250 non-null object
終値 250 non-null object
出来高 250 non-null object
売買代金 250 non-null object
dtypes: object(7)
memory usage: 15.6+ KB
In [58]:
#df_pigion_recent250['日付'] = df_pigion_recent250['日付'] .astype(datetime)
df_pigion_recent250['始値'] = df_pigion_recent250['始値'] .astype(float)
df_pigion_recent250['高値'] = df_pigion_recent250['高値'] .astype(float)
df_pigion_recent250['安値'] = df_pigion_recent250['安値'] .astype(float)
df_pigion_recent250['終値'] = df_pigion_recent250['終値'] .astype(float)
df_pigion_recent250['出来高'] = df_pigion_recent250['出来高'] .astype(int)
df_pigion_recent250['売買代金'] = df_pigion_recent250['売買代金'] .astype(int)
In [53]:
df_pigion_recent250.info()
<class 'pandas.core.frame.DataFrame'>
Int64Index: 250 entries, 0 to 249
Data columns (total 7 columns):
日付 250 non-null object
始値 250 non-null float64
高値 250 non-null float64
安値 250 non-null float64
終値 250 non-null float64
出来高 250 non-null int64
売買代金 250 non-null int64
dtypes: float64(4), int64(2), object(1)
memory usage: 15.6+ KB
In [60]:
df_pigion_recent250.plot(x='日付',y=['始値','終値','高値'],marker='o',linestyle='')
Out[60]:
<matplotlib.axes._subplots.AxesSubplot at 0x11adaa3c8>

日付で並び替え
df_pigion_recent250.sort('日付').plot(x='日付',y=['始値','終値','高値'],marker='o',linestyle='')
動作確認OK。
2015年4月までは9000円台だった。これは実質は外れ値になるので排除したい。
0-249 --> 0-242へ。
これはまた次回。