Zaoqi's Blog -> Python数据分析教程 -> 图解Pandas ->
股票数据分析
股票数据分析¶
在线刷题
检查 or 强化 Pandas
数据分析操作?👉在线体验「Pandas进阶修炼300题」
Note
本页面代码可以在线编辑、执行!
本页面数据说明¶
为了更好的介绍相关操作,本页面使用 某股票数据 数据进行展开,你应该对数据字段、数值、类型等相关信息做一个大致了解!
import pandas as pd
import warnings
warnings.filterwarnings("ignore")
df1 = pd.read_csv("000001_daily.csv")
df2 = pd.read_csv("000001_5min.csv")
df1.head()
日期 | 开盘 | 收盘 | 最高 | 最低 | 成交量 | 成交额 | 振幅 | 涨跌幅 | 涨跌额 | 换手率 | |
---|---|---|---|---|---|---|---|---|---|---|---|
0 | 2017/1/3 | 8.27 | 8.32 | 8.34 | 8.25 | 459840 | 420595184 | 1.09 | 0.73 | 0.06 | 0.31 |
1 | 2017/1/4 | 8.31 | 8.32 | 8.34 | 8.30 | 449330 | 411503440 | 0.48 | 0.00 | 0.00 | 0.31 |
2 | 2017/1/5 | 8.33 | 8.33 | 8.34 | 8.31 | 344373 | 315769696 | 0.36 | 0.12 | 0.01 | 0.24 |
3 | 2017/1/6 | 8.33 | 8.29 | 8.33 | 8.27 | 358154 | 327176432 | 0.72 | -0.48 | -0.04 | 0.24 |
4 | 2017/1/9 | 8.29 | 8.31 | 8.33 | 8.27 | 361082 | 329994608 | 0.72 | 0.24 | 0.02 | 0.21 |
时间类型转换¶
将 df1 和 df2 的 日期 列转换为 pandas 支持的时间格式
df1['日期'] = pd.to_datetime(df1['日期'])
df2['时间'] = pd.to_datetime(df2['时间'])
# df1['日期'] = df1['日期'].astype('datetime64[ns]')
日期筛选¶
按区间筛选¶
筛选出 df2 时间在 2021-08-03 09:35:00
与 2021-08-04 15:00:00
之间的数据
df2[(df2['时间'] > '2021-08-03 09:35:00') & (df2['时间'] < '2021-08-04 15:00:00')]
时间 | 开盘 | 收盘 | 最高 | 最低 | 涨跌幅 | 涨跌额 | 成交量 | 成交额 | 振幅 | 换手率 | |
---|---|---|---|---|---|---|---|---|---|---|---|
1 | 2021-08-03 09:40:00 | 17.77 | 17.76 | 17.83 | 17.66 | -0.11 | -0.02 | 41508 | 73683531 | 0.96 | 0.02 |
2 | 2021-08-03 09:45:00 | 17.77 | 17.77 | 17.83 | 17.73 | 0.06 | 0.01 | 18521 | 32915794 | 0.56 | 0.01 |
3 | 2021-08-03 09:50:00 | 17.77 | 17.72 | 17.78 | 17.70 | -0.28 | -0.05 | 24424 | 43323693 | 0.45 | 0.01 |
4 | 2021-08-03 09:55:00 | 17.71 | 17.77 | 17.78 | 17.70 | 0.28 | 0.05 | 23197 | 41110937 | 0.45 | 0.01 |
5 | 2021-08-03 10:00:00 | 17.78 | 17.81 | 17.83 | 17.74 | 0.23 | 0.04 | 18111 | 32208076 | 0.51 | 0.01 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
90 | 2021-08-04 14:35:00 | 17.81 | 17.81 | 17.83 | 17.78 | 0.00 | 0.00 | 12903 | 22973276 | 0.28 | 0.01 |
91 | 2021-08-04 14:40:00 | 17.82 | 17.80 | 17.85 | 17.79 | -0.06 | -0.01 | 12254 | 21835743 | 0.34 | 0.01 |
92 | 2021-08-04 14:45:00 | 17.82 | 17.82 | 17.84 | 17.80 | 0.11 | 0.02 | 9893 | 17631076 | 0.22 | 0.01 |
93 | 2021-08-04 14:50:00 | 17.81 | 17.80 | 17.83 | 17.80 | -0.11 | -0.02 | 12127 | 21603534 | 0.17 | 0.01 |
94 | 2021-08-04 14:55:00 | 17.80 | 17.81 | 17.84 | 17.79 | 0.06 | 0.01 | 17028 | 30332096 | 0.28 | 0.01 |
94 rows × 11 columns
按指定时间筛选¶
筛选 df2 时间为 2021-08-03 的全部数据
df2.set_index('时间').truncate(after=pd.Timestamp('2021-08-04'))
开盘 | 收盘 | 最高 | 最低 | 涨跌幅 | 涨跌额 | 成交量 | 成交额 | 振幅 | 换手率 | |
---|---|---|---|---|---|---|---|---|---|---|
时间 | ||||||||||
2021-08-03 09:35:00 | 17.99 | 17.78 | 18.02 | 17.75 | -1.28 | -0.23 | 52807 | 94339287 | 1.50 | 0.03 |
2021-08-03 09:40:00 | 17.77 | 17.76 | 17.83 | 17.66 | -0.11 | -0.02 | 41508 | 73683531 | 0.96 | 0.02 |
2021-08-03 09:45:00 | 17.77 | 17.77 | 17.83 | 17.73 | 0.06 | 0.01 | 18521 | 32915794 | 0.56 | 0.01 |
2021-08-03 09:50:00 | 17.77 | 17.72 | 17.78 | 17.70 | -0.28 | -0.05 | 24424 | 43323693 | 0.45 | 0.01 |
2021-08-03 09:55:00 | 17.71 | 17.77 | 17.78 | 17.70 | 0.28 | 0.05 | 23197 | 41110937 | 0.45 | 0.01 |
2021-08-03 10:00:00 | 17.78 | 17.81 | 17.83 | 17.74 | 0.23 | 0.04 | 18111 | 32208076 | 0.51 | 0.01 |
2021-08-03 10:05:00 | 17.83 | 17.84 | 17.91 | 17.79 | 0.17 | 0.03 | 28273 | 50498772 | 0.67 | 0.01 |
2021-08-03 10:10:00 | 17.84 | 18.01 | 18.01 | 17.83 | 0.95 | 0.17 | 37675 | 67585497 | 1.01 | 0.02 |
2021-08-03 10:15:00 | 18.01 | 18.05 | 18.09 | 18.01 | 0.22 | 0.04 | 31315 | 56528108 | 0.44 | 0.02 |
2021-08-03 10:20:00 | 18.04 | 18.00 | 18.07 | 17.98 | -0.28 | -0.05 | 25998 | 46873326 | 0.50 | 0.01 |
2021-08-03 10:25:00 | 18.01 | 17.99 | 18.03 | 17.98 | -0.06 | -0.01 | 19840 | 35724912 | 0.28 | 0.01 |
2021-08-03 10:30:00 | 17.99 | 17.89 | 18.00 | 17.89 | -0.56 | -0.10 | 22437 | 40295707 | 0.61 | 0.01 |
2021-08-03 10:35:00 | 17.89 | 17.96 | 17.97 | 17.89 | 0.39 | 0.07 | 16344 | 29302241 | 0.45 | 0.01 |
2021-08-03 10:40:00 | 17.97 | 17.94 | 17.98 | 17.94 | -0.11 | -0.02 | 13929 | 25017058 | 0.22 | 0.01 |
2021-08-03 10:45:00 | 17.94 | 17.99 | 18.04 | 17.90 | 0.28 | 0.05 | 20556 | 36934160 | 0.78 | 0.01 |
2021-08-03 10:50:00 | 18.00 | 18.11 | 18.11 | 17.99 | 0.67 | 0.12 | 24688 | 44603411 | 0.67 | 0.01 |
2021-08-03 10:55:00 | 18.11 | 18.01 | 18.15 | 18.01 | -0.55 | -0.10 | 23020 | 41643532 | 0.77 | 0.01 |
2021-08-03 11:00:00 | 18.01 | 18.03 | 18.05 | 17.99 | 0.11 | 0.02 | 12102 | 21795475 | 0.33 | 0.01 |
2021-08-03 11:05:00 | 18.04 | 18.03 | 18.05 | 18.00 | 0.00 | 0.00 | 17303 | 31197226 | 0.28 | 0.01 |
2021-08-03 11:10:00 | 18.03 | 18.02 | 18.04 | 18.00 | -0.06 | -0.01 | 12736 | 22940014 | 0.22 | 0.01 |
2021-08-03 11:15:00 | 18.03 | 18.00 | 18.03 | 18.00 | -0.11 | -0.02 | 12273 | 22104969 | 0.17 | 0.01 |
2021-08-03 11:20:00 | 18.02 | 18.07 | 18.10 | 18.01 | 0.39 | 0.07 | 20951 | 37844518 | 0.50 | 0.01 |
2021-08-03 11:25:00 | 18.08 | 18.02 | 18.09 | 18.01 | -0.28 | -0.05 | 15905 | 28711245 | 0.44 | 0.01 |
2021-08-03 11:30:00 | 18.02 | 18.02 | 18.05 | 18.00 | 0.00 | 0.00 | 13814 | 24893817 | 0.28 | 0.01 |
2021-08-03 13:05:00 | 18.02 | 18.01 | 18.04 | 18.00 | -0.06 | -0.01 | 16530 | 29783440 | 0.22 | 0.01 |
2021-08-03 13:10:00 | 18.01 | 18.04 | 18.07 | 18.01 | 0.17 | 0.03 | 14666 | 26464258 | 0.33 | 0.01 |
2021-08-03 13:15:00 | 18.04 | 17.99 | 18.05 | 17.99 | -0.28 | -0.05 | 13880 | 25011176 | 0.33 | 0.01 |
2021-08-03 13:20:00 | 17.99 | 17.98 | 18.02 | 17.98 | -0.06 | -0.01 | 13451 | 24208140 | 0.22 | 0.01 |
2021-08-03 13:25:00 | 17.98 | 18.00 | 18.01 | 17.97 | 0.11 | 0.02 | 14024 | 25229291 | 0.22 | 0.01 |
2021-08-03 13:30:00 | 18.00 | 18.01 | 18.05 | 17.99 | 0.06 | 0.01 | 15333 | 27633217 | 0.33 | 0.01 |
2021-08-03 13:35:00 | 18.01 | 18.00 | 18.03 | 17.98 | -0.06 | -0.01 | 16424 | 29582866 | 0.28 | 0.01 |
2021-08-03 13:40:00 | 18.00 | 17.99 | 18.02 | 17.98 | -0.06 | -0.01 | 14696 | 26452384 | 0.22 | 0.01 |
2021-08-03 13:45:00 | 18.00 | 17.99 | 18.02 | 17.98 | 0.00 | 0.00 | 14632 | 26334531 | 0.22 | 0.01 |
2021-08-03 13:50:00 | 18.01 | 17.99 | 18.01 | 17.98 | 0.00 | 0.00 | 11746 | 21134264 | 0.17 | 0.01 |
2021-08-03 13:55:00 | 17.98 | 17.94 | 18.00 | 17.92 | -0.28 | -0.05 | 17023 | 30591848 | 0.44 | 0.01 |
2021-08-03 14:00:00 | 17.93 | 17.95 | 17.96 | 17.93 | 0.06 | 0.01 | 8906 | 15983206 | 0.17 | 0.00 |
2021-08-03 14:05:00 | 17.95 | 17.94 | 17.96 | 17.93 | -0.06 | -0.01 | 9690 | 17392582 | 0.17 | 0.00 |
2021-08-03 14:10:00 | 17.95 | 17.93 | 17.96 | 17.93 | -0.06 | -0.01 | 10427 | 18707878 | 0.17 | 0.01 |
2021-08-03 14:15:00 | 17.93 | 17.92 | 17.96 | 17.92 | -0.06 | -0.01 | 10498 | 18828673 | 0.22 | 0.01 |
2021-08-03 14:20:00 | 17.93 | 17.92 | 17.94 | 17.91 | 0.00 | 0.00 | 16589 | 29733764 | 0.17 | 0.01 |
2021-08-03 14:25:00 | 17.91 | 17.93 | 17.94 | 17.90 | 0.06 | 0.01 | 17581 | 31496394 | 0.22 | 0.01 |
2021-08-03 14:30:00 | 17.92 | 17.94 | 17.96 | 17.91 | 0.06 | 0.01 | 12845 | 23035897 | 0.28 | 0.01 |
2021-08-03 14:35:00 | 17.94 | 17.93 | 17.94 | 17.90 | -0.06 | -0.01 | 14611 | 26183179 | 0.22 | 0.01 |
2021-08-03 14:40:00 | 17.93 | 17.93 | 17.94 | 17.90 | 0.00 | 0.00 | 12076 | 21636917 | 0.22 | 0.01 |
2021-08-03 14:45:00 | 17.90 | 17.93 | 17.93 | 17.89 | 0.00 | 0.00 | 16397 | 29359350 | 0.22 | 0.01 |
2021-08-03 14:50:00 | 17.93 | 17.97 | 17.98 | 17.91 | 0.22 | 0.04 | 19476 | 34965331 | 0.39 | 0.01 |
2021-08-03 14:55:00 | 17.96 | 17.93 | 17.97 | 17.91 | -0.22 | -0.04 | 17597 | 31563908 | 0.33 | 0.01 |
2021-08-03 15:00:00 | 17.92 | 17.89 | 17.94 | 17.89 | -0.22 | -0.04 | 20126 | 36034747 | 0.28 | 0.01 |
金融计算¶
涨跌幅¶
df1
新增一列 涨跌变化率,计算前后两日收盘价之差的变化率
注意:虽然我们的df1包含涨跌幅列,但是这个操作很常用,所以练习一下,结果可以用于验证
df1['涨跌变化率'] = (df1.收盘.pct_change()).apply(lambda x: format(x, '.2%'))
移动均值¶
计算收盘价的5日移动均线
df1.收盘.rolling(window=5).mean()
0 NaN
1 NaN
2 NaN
3 NaN
4 8.314
...
1141 18.672
1142 18.792
1143 19.298
1144 19.650
1145 19.676
Name: 收盘, Length: 1146, dtype: float64
移动均值(可视化)¶
同时计算并绘制 df1 的收盘价、5日均线、20日均线
df1.set_index("日期")['收盘'].plot()
df1.set_index("日期")['收盘'].rolling(5).mean().plot()
df1.set_index("日期")['收盘'].rolling(20).mean().plot()
<AxesSubplot:xlabel='日期'>
指数移动平均值(EMA)¶
根据 df1 计算 EMA20
df1['EMA20'] = df1['收盘'].ewm(span=20,min_periods=0,adjust=False,ignore_na=False).mean()
MACD¶
计算 df1 的 MACD 指标
exp1 = df1['收盘'].ewm(span=12, adjust=False).mean()
exp2 = df1['收盘'].ewm(span=26, adjust=False).mean()
df1['MACD'] = exp1 - exp2
df1['Signal line'] = df1['MACD'].ewm(span=9, adjust=False).mean()
布林指标¶
计算并绘制布林指标,计算方法参考百度百科
df1['former 30 days rolling Close mean'] = df1['收盘'].rolling(20).mean()
df1['upper bound'] = df1['former 30 days rolling Close mean'] + \
2*df1['收盘'].rolling(20).std() # 在这里我们取20天内的标准差
df1['lower bound'] = df1['former 30 days rolling Close mean'] - \
2*df1['收盘'].rolling(20).std()
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['Songti SC'] #设置中文,如果本句代码导致失效,可以点击https://mp.weixin.qq.com/s/WKOGvQP-6QUAP00ZXjhweg
df1.set_index("日期")[['收盘', 'former 30 days rolling Close mean','upper bound','lower bound' ]].plot(figsize=(16, 6))
plt.show()
日期移动¶
移动值¶
将 df1 的索引设置为日期,将 df1 数据向后移动一天
df1.set_index('日期').shift(1)
开盘 | 收盘 | 最高 | 最低 | 成交量 | 成交额 | 振幅 | 涨跌幅 | 涨跌额 | 换手率 | 涨跌 | 涨跌变化率 | EMA20 | MACD | Signal line | former 30 days rolling Close mean | upper bound | lower bound | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
日期 | ||||||||||||||||||
2017-01-03 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
2017-01-04 | 8.27 | 8.32 | 8.34 | 8.25 | 459840.0 | 4.205952e+08 | 1.09 | 0.73 | 0.06 | 0.31 | NaN | nan% | 8.320000 | 0.000000 | 0.000000 | NaN | NaN | NaN |
2017-01-05 | 8.31 | 8.32 | 8.34 | 8.30 | 449330.0 | 4.115034e+08 | 0.48 | 0.00 | 0.00 | 0.31 | 0.00 | 0.00% | 8.320000 | 0.000000 | 0.000000 | NaN | NaN | NaN |
2017-01-06 | 8.33 | 8.33 | 8.34 | 8.31 | 344373.0 | 3.157697e+08 | 0.36 | 0.12 | 0.01 | 0.24 | 0.01 | 0.12% | 8.320952 | 0.000798 | 0.000160 | NaN | NaN | NaN |
2017-01-09 | 8.33 | 8.29 | 8.33 | 8.27 | 358154.0 | 3.271764e+08 | 0.72 | -0.48 | -0.04 | 0.24 | -0.04 | -0.48% | 8.318005 | -0.001777 | -0.000228 | NaN | NaN | NaN |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
2021-09-08 | 18.60 | 19.24 | 19.56 | 18.35 | 1622344.0 | 3.067366e+09 | 6.56 | 4.28 | 0.79 | 0.84 | 0.79 | 4.28% | 18.816960 | -0.369698 | -0.414708 | 19.0895 | 20.861284 | 17.317716 |
2021-09-09 | 19.24 | 19.23 | 19.55 | 19.10 | 1026201.0 | 1.979771e+09 | 2.34 | -0.05 | -0.01 | 0.53 | -0.01 | -0.05% | 18.856297 | -0.293684 | -0.390503 | 19.0605 | 20.801346 | 17.319654 |
2021-09-10 | 19.11 | 19.00 | 19.15 | 18.80 | 739506.0 | 1.399536e+09 | 1.82 | -1.20 | -0.23 | 0.38 | -0.23 | -1.20% | 18.869983 | -0.249129 | -0.362229 | 19.0160 | 20.712503 | 17.319497 |
2021-09-13 | 18.89 | 20.57 | 20.77 | 18.84 | 2314945.0 | 4.668362e+09 | 10.16 | 8.26 | 1.57 | 1.19 | 1.57 | 8.26% | 19.031889 | -0.086141 | -0.307011 | 19.0500 | 20.844670 | 17.255330 |
2021-09-14 | 20.36 | 20.21 | 20.51 | 19.81 | 1297228.0 | 2.606152e+09 | 3.40 | -1.75 | -0.36 | 0.67 | -0.36 | -1.75% | 19.144090 | 0.013821 | -0.242845 | 19.0630 | 20.888620 | 17.237380 |
1146 rows × 18 columns
移动索引¶
将 df1 的索引设置为日期,并将全部日期向后移动一天
import datetime
df1.set_index('日期').shift(freq=datetime.timedelta(1))
开盘 | 收盘 | 最高 | 最低 | 成交量 | 成交额 | 振幅 | 涨跌幅 | 涨跌额 | 换手率 | 涨跌 | 涨跌变化率 | EMA20 | MACD | Signal line | former 30 days rolling Close mean | upper bound | lower bound | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
日期 | ||||||||||||||||||
2017-01-04 | 8.27 | 8.32 | 8.34 | 8.25 | 459840 | 420595184 | 1.09 | 0.73 | 0.06 | 0.31 | NaN | nan% | 8.320000 | 0.000000 | 0.000000 | NaN | NaN | NaN |
2017-01-05 | 8.31 | 8.32 | 8.34 | 8.30 | 449330 | 411503440 | 0.48 | 0.00 | 0.00 | 0.31 | 0.00 | 0.00% | 8.320000 | 0.000000 | 0.000000 | NaN | NaN | NaN |
2017-01-06 | 8.33 | 8.33 | 8.34 | 8.31 | 344373 | 315769696 | 0.36 | 0.12 | 0.01 | 0.24 | 0.01 | 0.12% | 8.320952 | 0.000798 | 0.000160 | NaN | NaN | NaN |
2017-01-07 | 8.33 | 8.29 | 8.33 | 8.27 | 358154 | 327176432 | 0.72 | -0.48 | -0.04 | 0.24 | -0.04 | -0.48% | 8.318005 | -0.001777 | -0.000228 | NaN | NaN | NaN |
2017-01-10 | 8.29 | 8.31 | 8.33 | 8.27 | 361082 | 329994608 | 0.72 | 0.24 | 0.02 | 0.21 | 0.02 | 0.24% | 8.317242 | -0.002179 | -0.000618 | NaN | NaN | NaN |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
2021-09-09 | 19.24 | 19.23 | 19.55 | 19.10 | 1026201 | 1979771472 | 2.34 | -0.05 | -0.01 | 0.53 | -0.01 | -0.05% | 18.856297 | -0.293684 | -0.390503 | 19.0605 | 20.801346 | 17.319654 |
2021-09-10 | 19.11 | 19.00 | 19.15 | 18.80 | 739506 | 1399536016 | 1.82 | -1.20 | -0.23 | 0.38 | -0.23 | -1.20% | 18.869983 | -0.249129 | -0.362229 | 19.0160 | 20.712503 | 17.319497 |
2021-09-11 | 18.89 | 20.57 | 20.77 | 18.84 | 2314945 | 4668361728 | 10.16 | 8.26 | 1.57 | 1.19 | 1.57 | 8.26% | 19.031889 | -0.086141 | -0.307011 | 19.0500 | 20.844670 | 17.255330 |
2021-09-14 | 20.36 | 20.21 | 20.51 | 19.81 | 1297228 | 2606152384 | 3.40 | -1.75 | -0.36 | 0.67 | -0.36 | -1.75% | 19.144090 | 0.013821 | -0.242845 | 19.0630 | 20.888620 | 17.237380 |
2021-09-15 | 20.18 | 19.37 | 20.27 | 19.27 | 1158173 | 2272080160 | 4.95 | -4.16 | -0.84 | 0.60 | -0.84 | -4.16% | 19.165606 | 0.024972 | -0.189281 | 19.0480 | 20.857479 | 17.238521 |
1146 rows × 18 columns
日期重采样¶
日 -> 周¶
按周对 df1 进行重采样,保留每周最后一个数据
df1.set_index('日期').resample('W').last()
开盘 | 收盘 | 最高 | 最低 | 成交量 | 成交额 | 振幅 | 涨跌幅 | 涨跌额 | 换手率 | 涨跌 | 涨跌变化率 | EMA20 | MACD | Signal line | former 30 days rolling Close mean | upper bound | lower bound | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
日期 | ||||||||||||||||||
2017-01-08 | 8.33 | 8.29 | 8.33 | 8.27 | 358154.0 | 3.271764e+08 | 0.72 | -0.48 | -0.04 | 0.24 | -0.04 | -0.48% | 8.318005 | -0.001777 | -0.000228 | NaN | NaN | NaN |
2017-01-15 | 8.30 | 8.32 | 8.35 | 8.28 | 434301.0 | 3.976019e+08 | 0.84 | 0.12 | 0.01 | 0.26 | 0.01 | 0.12% | 8.315026 | -0.002529 | -0.002001 | NaN | NaN | NaN |
2017-01-22 | 8.33 | 8.38 | 8.39 | 8.33 | 393329.0 | 3.618652e+08 | 0.72 | 0.48 | 0.04 | 0.23 | 0.04 | 0.48% | 8.323220 | 0.005576 | -0.000237 | NaN | NaN | NaN |
2017-01-29 | 8.43 | 8.49 | 8.50 | 8.42 | 420713.0 | 3.918443e+08 | 0.95 | 0.83 | 0.07 | 0.25 | 0.07 | 0.83% | 8.359773 | 0.029337 | 0.012089 | NaN | NaN | NaN |
2017-02-05 | 8.50 | 8.42 | 8.52 | 8.39 | 315472.0 | 2.926179e+08 | 1.53 | -0.82 | -0.07 | 0.19 | -0.07 | -0.82% | 8.365509 | 0.030296 | 0.015730 | NaN | NaN | NaN |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
2021-08-22 | 19.97 | 19.42 | 20.07 | 18.70 | 1614628.0 | 3.119153e+09 | 6.74 | -4.52 | -0.92 | 0.83 | -0.92 | -4.52% | 19.631205 | -0.142627 | -0.419982 | 18.8795 | 20.984246 | 16.774754 |
2021-08-29 | 18.56 | 18.39 | 18.88 | 18.31 | 728820.0 | 1.354409e+09 | 3.09 | -0.38 | -0.07 | 0.38 | -0.07 | -0.38% | 19.335072 | -0.307851 | -0.292708 | 19.1150 | 20.952578 | 17.277422 |
2021-09-05 | 18.50 | 18.04 | 18.50 | 17.70 | 1394819.0 | 2.523273e+09 | 4.35 | -1.96 | -0.36 | 0.72 | -0.36 | -1.96% | 18.806369 | -0.493470 | -0.416861 | 19.1445 | 20.911466 | 17.377534 |
2021-09-12 | 18.89 | 20.57 | 20.77 | 18.84 | 2314945.0 | 4.668362e+09 | 10.16 | 8.26 | 1.57 | 1.19 | 1.57 | 8.26% | 19.031889 | -0.086141 | -0.307011 | 19.0500 | 20.844670 | 17.255330 |
2021-09-19 | 20.18 | 19.37 | 20.27 | 19.27 | 1158173.0 | 2.272080e+09 | 4.95 | -4.16 | -0.84 | 0.60 | -0.84 | -4.16% | 19.165606 | 0.024972 | -0.189281 | 19.0480 | 20.857479 | 17.238521 |
246 rows × 18 columns
日 -> 月¶
按月对 df1 进行重采样,保留每月最后一个数据
df1.set_index('日期').resample('M').last()
开盘 | 收盘 | 最高 | 最低 | 成交量 | 成交额 | 振幅 | 涨跌幅 | 涨跌额 | 换手率 | 涨跌 | 涨跌变化率 | EMA20 | MACD | Signal line | former 30 days rolling Close mean | upper bound | lower bound | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
日期 | ||||||||||||||||||
2017-01-31 | 8.43 | 8.49 | 8.50 | 8.42 | 420713 | 391844288 | 0.95 | 0.83 | 0.07 | 0.25 | 0.07 | 0.83% | 8.359773 | 0.029337 | 0.012089 | NaN | NaN | NaN |
2017-02-28 | 8.59 | 8.64 | 8.67 | 8.58 | 369720 | 350366896 | 1.05 | 0.58 | 0.05 | 0.22 | 0.05 | 0.58% | 8.573112 | 0.074404 | 0.075472 | 8.5665 | 8.773460 | 8.359540 |
2017-03-31 | 8.24 | 8.33 | 8.34 | 8.24 | 633121 | 578579040 | 1.21 | 1.09 | 0.09 | 0.37 | 0.09 | 1.09% | 8.413994 | -0.073842 | -0.049755 | 8.4575 | 8.748768 | 8.166232 |
2017-04-30 | 8.12 | 8.15 | 8.15 | 8.08 | 286446 | 256106698 | 0.86 | 0.25 | 0.02 | 0.17 | 0.02 | 0.25% | 8.218865 | -0.078102 | -0.079294 | 8.2270 | 8.428896 | 8.025104 |
2017-05-31 | 8.26 | 8.36 | 8.39 | 8.22 | 1033211 | 948741888 | 2.06 | 1.21 | 0.10 | 0.61 | 0.10 | 1.21% | 8.056467 | 0.011297 | -0.052053 | 7.9735 | 8.314907 | 7.632093 |
2017-06-30 | 8.56 | 8.55 | 8.59 | 8.47 | 499633 | 468003520 | 1.40 | -0.47 | -0.04 | 0.30 | -0.04 | -0.47% | 8.368898 | 0.107020 | 0.081328 | 8.3430 | 8.612198 | 8.073802 |
2017-07-31 | 10.12 | 9.99 | 10.14 | 9.77 | 1575864 | 1671814032 | 3.68 | -0.70 | -0.07 | 0.93 | -0.07 | -0.70% | 9.708929 | 0.401497 | 0.434813 | 9.6690 | 11.022139 | 8.315861 |
2017-08-31 | 10.71 | 10.60 | 10.76 | 10.47 | 1151786 | 1297730592 | 2.70 | -1.40 | -0.15 | 0.68 | -0.15 | -1.40% | 10.224083 | 0.250813 | 0.182339 | 10.1250 | 11.030480 | 9.219520 |
2017-09-30 | 10.24 | 10.43 | 10.48 | 10.18 | 682280 | 753852528 | 2.94 | 2.25 | 0.23 | 0.40 | 0.23 | 2.25% | 10.512902 | 0.007831 | 0.083505 | 10.6590 | 11.128575 | 10.189425 |
2017-10-31 | 10.87 | 10.86 | 10.90 | 10.71 | 627491 | 721237472 | 1.75 | -0.18 | -0.02 | 0.37 | -0.02 | -0.18% | 10.726516 | 0.061093 | 0.063177 | 10.7060 | 11.164666 | 10.247334 |
2017-11-30 | 13.02 | 12.70 | 13.05 | 12.58 | 1379636 | 1866700880 | 3.58 | -3.35 | -0.44 | 0.82 | -0.44 | -3.35% | 12.629801 | 0.596790 | 0.642198 | 12.5160 | 14.678459 | 10.353541 |
2017-12-31 | 12.53 | 12.62 | 12.75 | 12.42 | 982916 | 1303222048 | 2.63 | 0.72 | 0.09 | 0.58 | 0.09 | 0.72% | 12.577670 | 0.089316 | 0.108042 | 12.5215 | 13.033227 | 12.009773 |
2018-01-31 | 12.92 | 13.37 | 13.37 | 12.85 | 1747729 | 2423104768 | 4.01 | 3.08 | 0.40 | 1.03 | 0.40 | 3.08% | 13.275908 | 0.181650 | 0.252009 | 13.2490 | 14.398387 | 12.099613 |
2018-02-28 | 11.42 | 11.37 | 11.51 | 11.25 | 1214146 | 1463313696 | 2.24 | -1.98 | -0.23 | 0.72 | -0.23 | -1.98% | 12.166929 | -0.425308 | -0.337732 | 12.3780 | 14.314428 | 10.441572 |
2018-03-31 | 10.36 | 10.22 | 10.37 | 10.20 | 752174 | 823438176 | 1.64 | -1.45 | -0.15 | 0.44 | -0.15 | -1.45% | 10.904021 | -0.439439 | -0.396420 | 10.9595 | 11.866792 | 10.052208 |
2018-04-30 | 10.81 | 10.17 | 10.83 | 9.95 | 2709796 | 2958464272 | 8.19 | -5.31 | -0.57 | 1.60 | -0.57 | -5.31% | 10.724916 | -0.081372 | -0.109566 | 10.5930 | 11.340039 | 9.845961 |
2018-05-31 | 9.43 | 9.50 | 9.51 | 9.34 | 987360 | 999216336 | 1.81 | 1.06 | 0.10 | 0.58 | 0.10 | 1.06% | 10.039416 | -0.252155 | -0.191171 | 10.0880 | 10.684502 | 9.491498 |
2018-06-30 | 8.33 | 8.41 | 8.45 | 8.28 | 675300 | 611346096 | 2.06 | 2.06 | 0.17 | 0.39 | 0.17 | 2.06% | 9.096154 | -0.391787 | -0.315595 | 9.1725 | 10.036368 | 8.308632 |
2018-07-31 | 8.83 | 8.88 | 8.95 | 8.71 | 720151 | 674484656 | 2.71 | 0.34 | 0.03 | 0.42 | 0.03 | 0.34% | 8.616982 | 0.004301 | -0.105048 | 8.4140 | 9.097225 | 7.730775 |
2018-08-31 | 9.59 | 9.59 | 9.78 | 9.56 | 1310865 | 1337898864 | 2.30 | 0.10 | 0.01 | 0.76 | 0.01 | 0.10% | 9.057319 | 0.287543 | 0.166752 | 8.8730 | 10.003665 | 7.742335 |
2018-09-30 | 10.24 | 10.51 | 10.73 | 10.24 | 2110243 | 2331358288 | 4.80 | 3.04 | 0.31 | 1.23 | 0.31 | 3.04% | 9.710813 | 0.304713 | 0.231171 | 9.6705 | 10.401454 | 8.939546 |
2018-10-31 | 10.41 | 10.37 | 10.45 | 10.21 | 1152684 | 1252156768 | 2.32 | 0.10 | 0.01 | 0.67 | 0.01 | 0.10% | 10.142958 | 0.229796 | 0.220981 | 10.1165 | 10.920288 | 9.312712 |
2018-11-30 | 9.68 | 9.82 | 9.82 | 9.63 | 594715 | 610571536 | 1.97 | 1.66 | 0.16 | 0.35 | 0.16 | 1.66% | 9.948735 | -0.093728 | -0.044225 | 10.0100 | 10.464498 | 9.555502 |
2018-12-31 | 8.77 | 8.84 | 8.92 | 8.77 | 576604 | 541571008 | 1.72 | 1.14 | 0.10 | 0.34 | 0.10 | 1.14% | 9.304771 | -0.303912 | -0.229095 | 9.4395 | 10.357747 | 8.521253 |
2019-01-31 | 10.44 | 10.56 | 10.66 | 10.40 | 831623 | 922602880 | 2.50 | 1.44 | 0.15 | 0.48 | 0.15 | 1.44% | 9.937361 | 0.276734 | 0.178894 | 9.8290 | 10.712364 | 8.945636 |
2019-02-28 | 11.90 | 11.82 | 12.07 | 11.73 | 1113100 | 1383110816 | 2.87 | -0.34 | -0.04 | 0.65 | -0.04 | -0.34% | 10.935832 | 0.482602 | 0.388196 | 10.8910 | 11.924581 | 9.857419 |
2019-03-31 | 11.72 | 12.28 | 12.28 | 11.67 | 1669506 | 2108295392 | 5.22 | 5.14 | 0.60 | 0.97 | 0.60 | 5.14% | 11.849661 | 0.183377 | 0.260493 | 12.0355 | 12.653424 | 11.417576 |
2019-04-30 | 13.45 | 13.31 | 13.51 | 13.05 | 1116570 | 1542958576 | 3.39 | -1.84 | -0.25 | 0.65 | -0.25 | -1.84% | 13.292738 | 0.336437 | 0.423715 | 13.4270 | 14.208041 | 12.645959 |
2019-05-31 | 11.62 | 11.64 | 11.86 | 11.57 | 686794 | 839375712 | 2.48 | -0.34 | -0.04 | 0.40 | -0.04 | -0.34% | 12.069663 | -0.265725 | -0.246701 | 11.9550 | 12.445306 | 11.464694 |
2019-06-30 | 13.33 | 13.38 | 13.39 | 13.18 | 498094 | 682679968 | 1.58 | 0.53 | 0.07 | 0.29 | 0.07 | 0.53% | 12.589743 | 0.313734 | 0.167801 | 12.3020 | 13.738188 | 10.865812 |
2019-07-31 | 13.90 | 13.73 | 13.92 | 13.68 | 634723 | 899227872 | 1.72 | -1.72 | -0.24 | 0.37 | -0.24 | -1.72% | 13.504316 | 0.245858 | 0.241181 | 13.5060 | 14.024800 | 12.987200 |
2019-08-31 | 13.89 | 13.76 | 13.99 | 13.70 | 798501 | 1136119664 | 2.11 | 0.22 | 0.03 | 0.47 | 0.03 | 0.22% | 13.955094 | 0.071912 | 0.170015 | 14.0210 | 15.087581 | 12.954419 |
2019-09-30 | 15.35 | 15.19 | 15.49 | 15.17 | 1046363 | 1645828528 | 2.06 | -2.00 | -0.31 | 0.54 | -0.31 | -2.00% | 14.642265 | 0.347402 | 0.242229 | 14.4925 | 15.563945 | 13.421055 |
2019-10-31 | 16.02 | 15.86 | 16.07 | 15.84 | 862569 | 1407006432 | 1.43 | -1.06 | -0.17 | 0.44 | -0.17 | -1.06% | 15.976129 | 0.339469 | 0.446000 | 16.1580 | 16.983963 | 15.332037 |
2019-11-30 | 15.14 | 14.89 | 15.15 | 14.78 | 653867 | 1001451104 | 2.45 | -1.33 | -0.20 | 0.34 | -0.20 | -1.33% | 15.586805 | -0.238369 | -0.106934 | 15.8000 | 16.907829 | 14.692171 |
2019-12-31 | 16.17 | 16.05 | 16.23 | 15.91 | 704442 | 1154704352 | 1.98 | -0.74 | -0.12 | 0.36 | -0.12 | -0.74% | 15.837680 | 0.168803 | 0.114792 | 15.6875 | 16.658314 | 14.716686 |
2020-01-31 | 15.52 | 15.14 | 15.52 | 14.99 | 1100592 | 1723394336 | 3.38 | -3.51 | -0.55 | 0.57 | -0.55 | -3.51% | 15.975078 | -0.075053 | 0.071022 | 16.1800 | 16.985377 | 15.374623 |
2020-02-29 | 14.45 | 14.10 | 14.64 | 14.06 | 1300644 | 1906892416 | 3.94 | -4.15 | -0.61 | 0.67 | -0.61 | -4.15% | 14.789529 | -0.222628 | -0.237305 | 14.5100 | 15.312417 | 13.707583 |
2020-03-31 | 12.65 | 12.40 | 12.69 | 12.38 | 513370 | 662915472 | 2.47 | -1.12 | -0.14 | 0.26 | -0.14 | -1.12% | 13.061722 | -0.590896 | -0.597096 | 13.2205 | 15.311931 | 11.129069 |
2020-04-30 | 13.62 | 13.53 | 13.92 | 13.48 | 819540 | 1155968240 | 3.23 | -0.66 | -0.09 | 0.42 | -0.09 | -0.66% | 12.911223 | 0.079692 | -0.091462 | 12.6885 | 13.519689 | 11.857311 |
2020-05-31 | 12.83 | 12.82 | 12.86 | 12.74 | 457808 | 594502128 | 0.93 | -0.54 | -0.07 | 0.24 | -0.07 | -0.54% | 12.887432 | -0.075630 | -0.040344 | 13.0605 | 13.790503 | 12.330497 |
2020-06-30 | 12.65 | 12.62 | 12.70 | 12.54 | 937940 | 1199181600 | 1.27 | 0.00 | 0.00 | 0.48 | 0.00 | 0.00% | 12.777390 | -0.131097 | -0.095965 | 12.9290 | 13.694847 | 12.163153 |
2020-07-31 | 13.10 | 13.16 | 13.35 | 13.07 | 1165822 | 1559068288 | 2.12 | -0.23 | -0.03 | 0.60 | -0.03 | -0.23% | 13.676416 | -0.104207 | 0.071230 | 14.1905 | 15.848876 | 12.532124 |
2020-08-31 | 15.12 | 14.90 | 15.50 | 14.81 | 1797130 | 2760350320 | 4.62 | -0.33 | -0.05 | 0.93 | -0.05 | -0.33% | 14.329986 | 0.232792 | 0.195512 | 14.2745 | 15.226782 | 13.322218 |
2020-09-30 | 14.62 | 14.99 | 15.09 | 14.62 | 1217065 | 1838547600 | 3.21 | 2.53 | 0.37 | 0.63 | 0.37 | 2.53% | 15.043294 | 0.120394 | 0.215259 | 15.1285 | 15.778885 | 14.478115 |
2020-10-31 | 17.56 | 17.57 | 18.18 | 17.42 | 1007804 | 1813064336 | 4.32 | -0.11 | -0.02 | 0.52 | -0.02 | -0.11% | 16.799087 | 0.678363 | 0.637274 | 16.5465 | 18.837721 | 14.255279 |
2020-11-30 | 19.72 | 19.56 | 20.70 | 19.41 | 1581441 | 3213680464 | 6.61 | 0.20 | 0.04 | 0.81 | 0.04 | 0.20% | 18.401708 | 0.681858 | 0.583008 | 18.2485 | 19.926711 | 16.570289 |
2020-12-31 | 19.03 | 19.16 | 19.40 | 18.84 | 924503 | 1781736288 | 2.94 | 0.74 | 0.14 | 0.48 | 0.14 | 0.74% | 18.553552 | 0.104339 | 0.051644 | 18.5090 | 19.377584 | 17.640416 |
2021-01-31 | 22.63 | 22.91 | 23.36 | 22.53 | 1240258 | 2864101424 | 3.67 | 1.24 | 0.28 | 0.64 | 0.28 | 1.24% | 21.340373 | 1.021672 | 0.905720 | 21.0670 | 24.103827 | 18.030173 |
2021-02-28 | 21.42 | 21.20 | 21.78 | 21.03 | 1124977 | 2424653760 | 3.42 | -3.24 | -0.71 | 0.58 | -0.71 | -3.24% | 22.587741 | 0.209554 | 0.673290 | 23.1920 | 25.486934 | 20.897066 |
2021-03-31 | 21.59 | 21.83 | 21.89 | 21.42 | 777028 | 1699922176 | 2.16 | 0.37 | 0.08 | 0.40 | 0.08 | 0.37% | 21.367022 | -0.159452 | -0.266009 | 21.2275 | 22.495700 | 19.959300 |
2021-04-30 | 23.17 | 23.11 | 23.31 | 22.83 | 561981 | 1308177200 | 2.05 | -1.28 | -0.30 | 0.29 | -0.30 | -1.28% | 22.125681 | 0.502633 | 0.272419 | 21.7540 | 24.001248 | 19.506752 |
2021-05-31 | 24.33 | 24.20 | 24.53 | 23.91 | 515351 | 1244209040 | 2.53 | -1.22 | -0.30 | 0.27 | -0.30 | -1.22% | 23.717712 | 0.590754 | 0.567379 | 23.7655 | 24.919267 | 22.611733 |
2021-06-30 | 22.36 | 22.62 | 22.93 | 22.35 | 403435 | 913285184 | 2.60 | 1.25 | 0.28 | 0.21 | 0.28 | 1.25% | 23.181017 | -0.243393 | -0.122945 | 23.3965 | 24.896090 | 21.896910 |
2021-07-31 | 17.92 | 17.69 | 18.05 | 17.24 | 950156 | 1679747312 | 4.51 | -1.50 | -0.27 | 0.49 | -0.27 | -1.50% | 20.075455 | -1.246638 | -0.945724 | 20.4435 | 23.662851 | 17.224149 |
2021-08-31 | 17.72 | 17.80 | 17.93 | 17.31 | 1174868 | 2072006848 | 3.50 | 0.45 | 0.08 | 0.61 | 0.08 | 0.45% | 19.049708 | -0.464633 | -0.344565 | 19.0960 | 20.987014 | 17.204986 |
2021-09-30 | 20.18 | 19.37 | 20.27 | 19.27 | 1158173 | 2272080160 | 4.95 | -4.16 | -0.84 | 0.60 | -0.84 | -4.16% | 19.165606 | 0.024972 | -0.189281 | 19.0480 | 20.857479 | 17.238521 |
分钟 -> 日¶
按日对 df2 进行重采样,保留每天最后一个数据
df2.set_index('时间').resample('D').last()
开盘 | 收盘 | 最高 | 最低 | 涨跌幅 | 涨跌额 | 成交量 | 成交额 | 振幅 | 换手率 | |
---|---|---|---|---|---|---|---|---|---|---|
时间 | ||||||||||
2021-08-03 | 17.92 | 17.89 | 17.94 | 17.89 | -0.22 | -0.04 | 20126.0 | 36034747.0 | 0.28 | 0.01 |
2021-08-04 | 17.81 | 17.81 | 17.82 | 17.80 | 0.00 | 0.00 | 12422.0 | 22122442.0 | 0.11 | 0.01 |
2021-08-05 | 17.64 | 17.68 | 17.68 | 17.64 | 0.17 | 0.03 | 15602.0 | 27568733.0 | 0.23 | 0.01 |
2021-08-06 | 17.84 | 17.86 | 17.87 | 17.84 | 0.06 | 0.01 | 13251.0 | 23647402.0 | 0.17 | 0.01 |
2021-08-07 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
2021-08-08 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
2021-08-09 | 19.07 | 19.06 | 19.09 | 19.06 | -0.16 | -0.03 | 16831.0 | 32092450.0 | 0.16 | 0.01 |
2021-08-10 | 19.72 | 19.73 | 19.74 | 19.70 | 0.05 | 0.01 | 14968.0 | 29523092.0 | 0.20 | 0.01 |
2021-08-11 | 19.74 | 19.81 | 19.81 | 19.74 | 0.35 | 0.07 | 17181.0 | 34015140.0 | 0.35 | 0.01 |
2021-08-12 | 19.89 | 19.89 | 19.89 | 19.87 | 0.00 | 0.00 | 7066.0 | 14051666.0 | 0.10 | 0.00 |
2021-08-13 | 19.87 | 19.89 | 19.89 | 19.85 | 0.20 | 0.04 | 11754.0 | 23367450.0 | 0.20 | 0.01 |
2021-08-14 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
2021-08-15 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
2021-08-16 | 19.91 | 19.95 | 19.95 | 19.89 | 0.20 | 0.04 | 8498.0 | 16936079.0 | 0.30 | 0.00 |
2021-08-17 | 19.69 | 19.67 | 19.70 | 19.66 | -0.15 | -0.03 | 7809.0 | 15366451.0 | 0.20 | 0.00 |
2021-08-18 | 20.66 | 20.62 | 20.69 | 20.62 | -0.24 | -0.05 | 25252.0 | 52116616.0 | 0.34 | 0.01 |
2021-08-19 | 20.32 | 20.34 | 20.34 | 20.31 | 0.15 | 0.03 | 13753.0 | 27959791.0 | 0.15 | 0.01 |
2021-08-20 | 19.43 | 19.42 | 19.43 | 19.39 | 0.00 | 0.00 | 24246.0 | 47066098.0 | 0.21 | 0.01 |
2021-08-21 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
2021-08-22 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
2021-08-23 | 19.28 | 19.30 | 19.30 | 19.28 | 0.16 | 0.03 | 10652.0 | 20550733.0 | 0.10 | 0.01 |
2021-08-24 | 19.35 | 19.36 | 19.40 | 19.34 | 0.10 | 0.02 | 15313.0 | 29654613.0 | 0.31 | 0.01 |
2021-08-25 | 19.13 | 19.16 | 19.16 | 19.12 | 0.16 | 0.03 | 13365.0 | 25584226.0 | 0.21 | 0.01 |
2021-08-26 | 18.49 | 18.46 | 18.50 | 18.46 | -0.16 | -0.03 | 19175.0 | 35413342.0 | 0.22 | 0.01 |
2021-08-27 | 18.37 | 18.39 | 18.39 | 18.33 | 0.05 | 0.01 | 17200.0 | 31599250.0 | 0.33 | 0.01 |
2021-08-28 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
2021-08-29 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
2021-08-30 | 17.70 | 17.72 | 17.72 | 17.68 | 0.11 | 0.02 | 21632.0 | 38313644.0 | 0.23 | 0.01 |
2021-08-31 | 17.79 | 17.80 | 17.81 | 17.78 | 0.00 | 0.00 | 31650.0 | 56333592.0 | 0.17 | 0.02 |
2021-09-01 | 17.83 | 17.88 | 17.88 | 17.83 | 0.22 | 0.04 | 36280.0 | 64831004.0 | 0.28 | 0.02 |
2021-09-02 | 18.37 | 18.40 | 18.44 | 18.34 | 0.22 | 0.04 | 53423.0 | 98264475.0 | 0.54 | 0.03 |
2021-09-03 | 18.06 | 18.04 | 18.07 | 18.04 | -0.11 | -0.02 | 24983.0 | 45082686.0 | 0.17 | 0.01 |
2021-09-04 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
2021-09-05 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
2021-09-06 | 18.46 | 18.45 | 18.47 | 18.45 | 0.00 | 0.00 | 23588.0 | 43525979.0 | 0.11 | 0.01 |
2021-09-07 | 19.22 | 19.24 | 19.25 | 19.20 | 0.16 | 0.03 | 32054.0 | 61625241.0 | 0.26 | 0.02 |
2021-09-08 | 19.21 | 19.23 | 19.23 | 19.19 | 0.16 | 0.03 | 16550.0 | 31803231.0 | 0.21 | 0.01 |
2021-09-09 | 18.97 | 19.00 | 19.00 | 18.97 | 0.16 | 0.03 | 19752.0 | 37520759.0 | 0.16 | 0.01 |
2021-09-10 | 20.60 | 20.57 | 20.62 | 20.57 | -0.15 | -0.03 | 38082.0 | 78398933.0 | 0.24 | 0.02 |
2021-09-11 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
2021-09-12 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
2021-09-13 | 20.20 | 20.21 | 20.22 | 20.19 | 0.05 | 0.01 | 17593.0 | 35555623.0 | 0.15 | 0.01 |
低频 -> 高频¶
将 df2 的 5分钟 数据改为 3分钟,缺失数据向前填充
df_3min = df2.set_index('时间').resample('3min').last()
df_3min.ffill()
开盘 | 收盘 | 最高 | 最低 | 涨跌幅 | 涨跌额 | 成交量 | 成交额 | 振幅 | 换手率 | |
---|---|---|---|---|---|---|---|---|---|---|
时间 | ||||||||||
2021-08-03 09:33:00 | 17.99 | 17.78 | 18.02 | 17.75 | -1.28 | -0.23 | 52807.0 | 94339287.0 | 1.50 | 0.03 |
2021-08-03 09:36:00 | 17.99 | 17.78 | 18.02 | 17.75 | -1.28 | -0.23 | 52807.0 | 94339287.0 | 1.50 | 0.03 |
2021-08-03 09:39:00 | 17.77 | 17.76 | 17.83 | 17.66 | -0.11 | -0.02 | 41508.0 | 73683531.0 | 0.96 | 0.02 |
2021-08-03 09:42:00 | 17.77 | 17.76 | 17.83 | 17.66 | -0.11 | -0.02 | 41508.0 | 73683531.0 | 0.96 | 0.02 |
2021-08-03 09:45:00 | 17.77 | 17.77 | 17.83 | 17.73 | 0.06 | 0.01 | 18521.0 | 32915794.0 | 0.56 | 0.01 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
2021-09-13 14:48:00 | 20.22 | 20.21 | 20.26 | 20.18 | 0.00 | 0.00 | 24419.0 | 49373556.0 | 0.40 | 0.01 |
2021-09-13 14:51:00 | 20.22 | 20.21 | 20.26 | 20.18 | 0.00 | 0.00 | 24419.0 | 49373556.0 | 0.40 | 0.01 |
2021-09-13 14:54:00 | 20.21 | 20.20 | 20.23 | 20.19 | -0.05 | -0.01 | 20769.0 | 41974013.0 | 0.20 | 0.01 |
2021-09-13 14:57:00 | 20.21 | 20.20 | 20.23 | 20.19 | -0.05 | -0.01 | 20769.0 | 41974013.0 | 0.20 | 0.01 |
2021-09-13 15:00:00 | 20.20 | 20.21 | 20.22 | 20.19 | 0.05 | 0.01 | 17593.0 | 35555623.0 | 0.15 | 0.01 |
19790 rows × 10 columns
On this page