import pandas as pd
df = pd.read_csv("SH600519.csv") # 读取股票文件
df.head(3)
#把时间列标准化时间格式
df['time_slot1']=pd.to_datetime(df['date'])
#输出这一天是周中的第几天,Monday=0, Sunday=6
df['week'] = df['time_slot1'].dt.dayofweek
df.head(3)
df.date = df.date.apply(pd.to_datetime)
df['month'] = df.date.apply(lambda x: x.month)
df['day'] = df.date.apply(lambda x: x.day)
df['year'] = df.date.apply(lambda x: x.year)
df.drop(['date'], 1, inplace = True)
df.head(3)
df["profit"] = df['close'] - df['open']
df.head(3)
import seaborn as sns
sns.set(style="whitegrid")
ax = sns.stripplot(x="month", y="profit",
data=df, jitter=True)
ax = sns.stripplot(x="week", y="profit",
data=df, jitter=True)
ax = sns.stripplot(x="day", y="profit",
data=df, jitter=True)
ax = sns.stripplot(x="year", y="profit",
data=df, jitter=True)