This commit is contained in:
liaozhaorun
2025-02-15 23:33:34 +08:00
parent 18d0876d86
commit 49fa31ac63
13 changed files with 2028 additions and 2580 deletions

View File

@@ -73,13 +73,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"is st...\n",
" ts_code trade_date is_st\n",
"0 688283.SH 20250207 False\n",
"1 002635.SZ 20250207 False\n",
"2 002463.SZ 20250207 False\n",
"3 603959.SH 20250207 False\n",
"4 688361.SH 20250207 False\n"
"is st...\n"
]
}
],
@@ -100,11 +94,8 @@
" for i in range(len(df)):\n",
" sds = df.iloc[i, 2]\n",
" eds = df.iloc[i, 3]\n",
" # sd = datetime.strptime(sds, '%Y%m%d')\n",
" if eds == None:\n",
" ed = datetime.now()\n",
" # else:\n",
" # ed = datetime.strptime(eds, '%Y%m%d')\n",
" if eds is None or eds is pd.NaT:\n",
" eds = datetime.now()\n",
" if (target_date - sds).days >= 0 and (target_date - eds).days <= 0:\n",
" return True\n",
" return False\n",
@@ -116,11 +107,54 @@
" lambda row: is_st(name_change_dict, row['ts_code'], row['trade_date']), axis=1\n",
")\n",
"\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "c74bc633-fc73-48c2-bb44-0a798d2cf070",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Empty DataFrame\n",
"Columns: [ts_code, trade_date, close, turnover_rate, turnover_rate_f, volume_ratio, pe, pe_ttm, pb, ps, ps_ttm, dv_ratio, dv_ttm, total_share, float_share, free_share, total_mv, circ_mv, is_st]\n",
"Index: []\n"
]
}
],
"source": [
"print(daily_basic[(daily_basic['is_st'] != True) & (daily_basic['is_st'] != False)])"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "0464ce15-320c-40d4-b499-2e18bac5910f",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" ts_code trade_date is_st\n",
"0 002512.SZ 20250211 False\n",
"1 600966.SH 20250211 False\n",
"2 600358.SH 20250211 True\n",
"3 002893.SZ 20250211 False\n",
"4 300648.SZ 20250211 False\n"
]
}
],
"source": [
"# 保存结果到新的 HDF5 文件\n",
"daily_basic.to_hdf('../../data/daily_basic.h5', key='daily_basic', mode='w', format='table')\n",
"\n",
"# 输出部分结果\n",
"print(daily_basic[['ts_code', 'trade_date', 'is_st']].head())\n"
"print(daily_basic[['ts_code', 'trade_date', 'is_st']].head())"
]
},
{