You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1010 lines
41 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "139fd1cb-aedf-4186-8408-4d630ba69599",
"metadata": {},
"outputs": [],
"source": [
"import dolphindb as ddb\n",
"\n",
"sess = ddb.session(\"192.168.1.167\", 8848)\n",
"sess.login('admin', '123456')"
]
},
{
"cell_type": "code",
"execution_count": 42,
"id": "86d6ce04-b5ae-410b-af8d-9d9b5d87a959",
"metadata": {},
"outputs": [],
"source": [
"sess.run(\"\"\"\n",
" dropFunctionView('pit_at_date')\n",
"\"\"\")"
]
},
{
"cell_type": "code",
"execution_count": 43,
"id": "5482fa63-23e7-48e7-9636-5628faef7b73",
"metadata": {},
"outputs": [],
"source": [
"sess.run(\"\"\"\n",
"def pit_at_date(table_name, date, report_period_list, code_partition_id) {\n",
"\tsource_table = loadTable(\"dfs://pit_stock_ts\", table_name);\n",
"\t\n",
"\tm_nDate = take(date, size(report_period_list));\n",
"\treport_period = report_period_list;\n",
"\t\n",
"\tquery_table = table(report_period, m_nDate);\n",
"\tquery_table_exp = select * from cj(query_table, select code from source_table where partition(code, code_partition_id) group by code map);\n",
"\t\n",
"\tsource_table_part = select source_table.* from ej(source_table, query_table_exp, `code`report_period) where partition(code, code_partition_id);\n",
"\t\n",
"\treturn select source_table_part.* from aj(query_table_exp, source_table_part, `code`report_period`m_nDate, `code`report_period`appear_at_date) where not isNull(source_table_part.code)\n",
"}\n",
"\n",
"addFunctionView(pit_at_date)\n",
"\"\"\")"
]
},
{
"cell_type": "code",
"execution_count": 44,
"id": "4e0eaa4d-80c9-4925-8496-a7d133fc0fda",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th>appear_in_period</th>\n",
" <th>TOT_OPER_REV</th>\n",
" <th>OPER_REV</th>\n",
" <th>INT_INC</th>\n",
" <th>INSUR_PREM_UNEARNED</th>\n",
" <th>HANDLING_CHRG_COMM_INC</th>\n",
" <th>NET_INC_OTHER_OPS</th>\n",
" <th>PLUS_NET_INC_OTHER_BUS</th>\n",
" <th>PLUS_NET_GAIN_CHG_FV</th>\n",
" <th>PLUS_NET_INVEST_INC</th>\n",
" <th>...</th>\n",
" <th>OTHER_INCOME</th>\n",
" <th>MEMO</th>\n",
" <th>ASSET_DISPOSAL_INCOME</th>\n",
" <th>CONTINUED_NET_PROFIT</th>\n",
" <th>END_NET_PROFIT</th>\n",
" <th>CREDIT_IMPAIRMENT_LOSS</th>\n",
" <th>RD_EXPENSE</th>\n",
" <th>STMNOTE_FINEXP</th>\n",
" <th>FIN_EXP_INT_INC</th>\n",
" <th>TOT_OPER_COST2</th>\n",
" </tr>\n",
" <tr>\n",
" <th>code</th>\n",
" <th>report_period</th>\n",
" <th>appear_at_date</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>000400.SZ</th>\n",
" <th>2018-12-31</th>\n",
" <th>2019-03-29</th>\n",
" <td>2018-12-31</td>\n",
" <td>8.216559e+09</td>\n",
" <td>8.216559e+09</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>73932.94</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>73932.94</td>\n",
" <td>...</td>\n",
" <td>72773000.86</td>\n",
" <td>nan</td>\n",
" <td>0.00</td>\n",
" <td>2.737097e+08</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>3.350267e+08</td>\n",
" <td>45075829.77</td>\n",
" <td>0.0</td>\n",
" <td>7.967406e+09</td>\n",
" </tr>\n",
" <tr>\n",
" <th>000558.SZ</th>\n",
" <th>2018-12-31</th>\n",
" <th>2019-04-26</th>\n",
" <td>2018-12-31</td>\n",
" <td>7.024741e+08</td>\n",
" <td>7.024741e+08</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>23984753.52</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>23984753.52</td>\n",
" <td>...</td>\n",
" <td>10174473.66</td>\n",
" <td>nan</td>\n",
" <td>-12902036.23</td>\n",
" <td>-5.424955e+07</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.000000e+00</td>\n",
" <td>39309311.59</td>\n",
" <td>0.0</td>\n",
" <td>6.444387e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>000677.SZ</th>\n",
" <th>2018-12-31</th>\n",
" <th>2019-03-29</th>\n",
" <td>2018-12-31</td>\n",
" <td>7.068198e+08</td>\n",
" <td>7.068198e+08</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>220497.76</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>220497.76</td>\n",
" <td>...</td>\n",
" <td>1157100.00</td>\n",
" <td>nan</td>\n",
" <td>-1852690.97</td>\n",
" <td>6.403690e+06</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>3.514984e+05</td>\n",
" <td>5234360.37</td>\n",
" <td>0.0</td>\n",
" <td>6.821367e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>000731.SZ</th>\n",
" <th>2018-12-31</th>\n",
" <th>2019-04-16</th>\n",
" <td>2018-12-31</td>\n",
" <td>2.639920e+09</td>\n",
" <td>2.639920e+09</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>4467512.66</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>4467512.66</td>\n",
" <td>...</td>\n",
" <td>3477372.43</td>\n",
" <td>nan</td>\n",
" <td>1992627.87</td>\n",
" <td>2.228619e+08</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.653546e+06</td>\n",
" <td>46581902.65</td>\n",
" <td>0.0</td>\n",
" <td>2.367904e+09</td>\n",
" </tr>\n",
" <tr>\n",
" <th>000752.SZ</th>\n",
" <th>2018-12-31</th>\n",
" <th>2019-05-16</th>\n",
" <td>2018-12-31</td>\n",
" <td>3.231171e+08</td>\n",
" <td>3.231171e+08</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>-43852162.57</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>-43852162.57</td>\n",
" <td>...</td>\n",
" <td>136549.44</td>\n",
" <td>nan</td>\n",
" <td>0.00</td>\n",
" <td>-3.830619e+08</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.000000e+00</td>\n",
" <td>0.00</td>\n",
" <td>0.0</td>\n",
" <td>3.135966e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <th>...</th>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>688039.SH</th>\n",
" <th>2018-12-31</th>\n",
" <th>2019-11-22</th>\n",
" <td>2018-12-31</td>\n",
" <td>2.035519e+08</td>\n",
" <td>2.035519e+08</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>156599.67</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>156599.67</td>\n",
" <td>...</td>\n",
" <td>15702563.93</td>\n",
" <td>nan</td>\n",
" <td>0.00</td>\n",
" <td>6.389806e+07</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>3.660990e+07</td>\n",
" <td>0.00</td>\n",
" <td>0.0</td>\n",
" <td>1.511902e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>688368.SH</th>\n",
" <th>2018-12-31</th>\n",
" <th>2019-09-17</th>\n",
" <td>2018-12-31</td>\n",
" <td>7.665912e+08</td>\n",
" <td>7.665912e+08</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>972435.31</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>972435.31</td>\n",
" <td>...</td>\n",
" <td>6568742.64</td>\n",
" <td>nan</td>\n",
" <td>0.00</td>\n",
" <td>0.000000e+00</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>6.081719e+07</td>\n",
" <td>0.00</td>\n",
" <td>0.0</td>\n",
" <td>6.890894e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>688396.SH</th>\n",
" <th>2018-12-31</th>\n",
" <th>2020-01-31</th>\n",
" <td>2018-12-31</td>\n",
" <td>6.270797e+09</td>\n",
" <td>6.270797e+09</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>10592096.66</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>10592096.66</td>\n",
" <td>...</td>\n",
" <td>91086261.29</td>\n",
" <td>nan</td>\n",
" <td>9434573.46</td>\n",
" <td>0.000000e+00</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>4.497610e+08</td>\n",
" <td>0.00</td>\n",
" <td>0.0</td>\n",
" <td>5.796301e+09</td>\n",
" </tr>\n",
" <tr>\n",
" <th>831010.NE</th>\n",
" <th>2018-12-31</th>\n",
" <th>2020-07-01</th>\n",
" <td>2018-12-31</td>\n",
" <td>2.936331e+08</td>\n",
" <td>2.936331e+08</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>262112.16</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>262112.16</td>\n",
" <td>...</td>\n",
" <td>380000.00</td>\n",
" <td>nan</td>\n",
" <td>-258845.78</td>\n",
" <td>4.129632e+07</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>5.236440e+05</td>\n",
" <td>254556.29</td>\n",
" <td>0.0</td>\n",
" <td>2.437095e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>833874.NE</th>\n",
" <th>2018-12-31</th>\n",
" <th>2020-06-29</th>\n",
" <td>2018-12-31</td>\n",
" <td>1.974978e+08</td>\n",
" <td>1.974978e+08</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>5841180.61</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>5841180.61</td>\n",
" <td>...</td>\n",
" <td>882100.00</td>\n",
" <td>nan</td>\n",
" <td>9554.96</td>\n",
" <td>9.051358e+07</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.092805e+07</td>\n",
" <td>0.00</td>\n",
" <td>0.0</td>\n",
" <td>1.021658e+08</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>91 rows × 66 columns</p>\n",
"</div>"
],
"text/plain": [
" appear_in_period TOT_OPER_REV \\\n",
"code report_period appear_at_date \n",
"000400.SZ 2018-12-31 2019-03-29 2018-12-31 8.216559e+09 \n",
"000558.SZ 2018-12-31 2019-04-26 2018-12-31 7.024741e+08 \n",
"000677.SZ 2018-12-31 2019-03-29 2018-12-31 7.068198e+08 \n",
"000731.SZ 2018-12-31 2019-04-16 2018-12-31 2.639920e+09 \n",
"000752.SZ 2018-12-31 2019-05-16 2018-12-31 3.231171e+08 \n",
"... ... ... \n",
"688039.SH 2018-12-31 2019-11-22 2018-12-31 2.035519e+08 \n",
"688368.SH 2018-12-31 2019-09-17 2018-12-31 7.665912e+08 \n",
"688396.SH 2018-12-31 2020-01-31 2018-12-31 6.270797e+09 \n",
"831010.NE 2018-12-31 2020-07-01 2018-12-31 2.936331e+08 \n",
"833874.NE 2018-12-31 2020-06-29 2018-12-31 1.974978e+08 \n",
"\n",
" OPER_REV INT_INC \\\n",
"code report_period appear_at_date \n",
"000400.SZ 2018-12-31 2019-03-29 8.216559e+09 0.0 \n",
"000558.SZ 2018-12-31 2019-04-26 7.024741e+08 0.0 \n",
"000677.SZ 2018-12-31 2019-03-29 7.068198e+08 0.0 \n",
"000731.SZ 2018-12-31 2019-04-16 2.639920e+09 0.0 \n",
"000752.SZ 2018-12-31 2019-05-16 3.231171e+08 0.0 \n",
"... ... ... \n",
"688039.SH 2018-12-31 2019-11-22 2.035519e+08 0.0 \n",
"688368.SH 2018-12-31 2019-09-17 7.665912e+08 0.0 \n",
"688396.SH 2018-12-31 2020-01-31 6.270797e+09 0.0 \n",
"831010.NE 2018-12-31 2020-07-01 2.936331e+08 0.0 \n",
"833874.NE 2018-12-31 2020-06-29 1.974978e+08 0.0 \n",
"\n",
" INSUR_PREM_UNEARNED \\\n",
"code report_period appear_at_date \n",
"000400.SZ 2018-12-31 2019-03-29 0.0 \n",
"000558.SZ 2018-12-31 2019-04-26 0.0 \n",
"000677.SZ 2018-12-31 2019-03-29 0.0 \n",
"000731.SZ 2018-12-31 2019-04-16 0.0 \n",
"000752.SZ 2018-12-31 2019-05-16 0.0 \n",
"... ... \n",
"688039.SH 2018-12-31 2019-11-22 0.0 \n",
"688368.SH 2018-12-31 2019-09-17 0.0 \n",
"688396.SH 2018-12-31 2020-01-31 0.0 \n",
"831010.NE 2018-12-31 2020-07-01 0.0 \n",
"833874.NE 2018-12-31 2020-06-29 0.0 \n",
"\n",
" HANDLING_CHRG_COMM_INC \\\n",
"code report_period appear_at_date \n",
"000400.SZ 2018-12-31 2019-03-29 0.0 \n",
"000558.SZ 2018-12-31 2019-04-26 0.0 \n",
"000677.SZ 2018-12-31 2019-03-29 0.0 \n",
"000731.SZ 2018-12-31 2019-04-16 0.0 \n",
"000752.SZ 2018-12-31 2019-05-16 0.0 \n",
"... ... \n",
"688039.SH 2018-12-31 2019-11-22 0.0 \n",
"688368.SH 2018-12-31 2019-09-17 0.0 \n",
"688396.SH 2018-12-31 2020-01-31 0.0 \n",
"831010.NE 2018-12-31 2020-07-01 0.0 \n",
"833874.NE 2018-12-31 2020-06-29 0.0 \n",
"\n",
" NET_INC_OTHER_OPS \\\n",
"code report_period appear_at_date \n",
"000400.SZ 2018-12-31 2019-03-29 73932.94 \n",
"000558.SZ 2018-12-31 2019-04-26 23984753.52 \n",
"000677.SZ 2018-12-31 2019-03-29 220497.76 \n",
"000731.SZ 2018-12-31 2019-04-16 4467512.66 \n",
"000752.SZ 2018-12-31 2019-05-16 -43852162.57 \n",
"... ... \n",
"688039.SH 2018-12-31 2019-11-22 156599.67 \n",
"688368.SH 2018-12-31 2019-09-17 972435.31 \n",
"688396.SH 2018-12-31 2020-01-31 10592096.66 \n",
"831010.NE 2018-12-31 2020-07-01 262112.16 \n",
"833874.NE 2018-12-31 2020-06-29 5841180.61 \n",
"\n",
" PLUS_NET_INC_OTHER_BUS \\\n",
"code report_period appear_at_date \n",
"000400.SZ 2018-12-31 2019-03-29 0.0 \n",
"000558.SZ 2018-12-31 2019-04-26 0.0 \n",
"000677.SZ 2018-12-31 2019-03-29 0.0 \n",
"000731.SZ 2018-12-31 2019-04-16 0.0 \n",
"000752.SZ 2018-12-31 2019-05-16 0.0 \n",
"... ... \n",
"688039.SH 2018-12-31 2019-11-22 0.0 \n",
"688368.SH 2018-12-31 2019-09-17 0.0 \n",
"688396.SH 2018-12-31 2020-01-31 0.0 \n",
"831010.NE 2018-12-31 2020-07-01 0.0 \n",
"833874.NE 2018-12-31 2020-06-29 0.0 \n",
"\n",
" PLUS_NET_GAIN_CHG_FV \\\n",
"code report_period appear_at_date \n",
"000400.SZ 2018-12-31 2019-03-29 0.0 \n",
"000558.SZ 2018-12-31 2019-04-26 0.0 \n",
"000677.SZ 2018-12-31 2019-03-29 0.0 \n",
"000731.SZ 2018-12-31 2019-04-16 0.0 \n",
"000752.SZ 2018-12-31 2019-05-16 0.0 \n",
"... ... \n",
"688039.SH 2018-12-31 2019-11-22 0.0 \n",
"688368.SH 2018-12-31 2019-09-17 0.0 \n",
"688396.SH 2018-12-31 2020-01-31 0.0 \n",
"831010.NE 2018-12-31 2020-07-01 0.0 \n",
"833874.NE 2018-12-31 2020-06-29 0.0 \n",
"\n",
" PLUS_NET_INVEST_INC ... \\\n",
"code report_period appear_at_date ... \n",
"000400.SZ 2018-12-31 2019-03-29 73932.94 ... \n",
"000558.SZ 2018-12-31 2019-04-26 23984753.52 ... \n",
"000677.SZ 2018-12-31 2019-03-29 220497.76 ... \n",
"000731.SZ 2018-12-31 2019-04-16 4467512.66 ... \n",
"000752.SZ 2018-12-31 2019-05-16 -43852162.57 ... \n",
"... ... ... \n",
"688039.SH 2018-12-31 2019-11-22 156599.67 ... \n",
"688368.SH 2018-12-31 2019-09-17 972435.31 ... \n",
"688396.SH 2018-12-31 2020-01-31 10592096.66 ... \n",
"831010.NE 2018-12-31 2020-07-01 262112.16 ... \n",
"833874.NE 2018-12-31 2020-06-29 5841180.61 ... \n",
"\n",
" OTHER_INCOME MEMO \\\n",
"code report_period appear_at_date \n",
"000400.SZ 2018-12-31 2019-03-29 72773000.86 nan \n",
"000558.SZ 2018-12-31 2019-04-26 10174473.66 nan \n",
"000677.SZ 2018-12-31 2019-03-29 1157100.00 nan \n",
"000731.SZ 2018-12-31 2019-04-16 3477372.43 nan \n",
"000752.SZ 2018-12-31 2019-05-16 136549.44 nan \n",
"... ... ... \n",
"688039.SH 2018-12-31 2019-11-22 15702563.93 nan \n",
"688368.SH 2018-12-31 2019-09-17 6568742.64 nan \n",
"688396.SH 2018-12-31 2020-01-31 91086261.29 nan \n",
"831010.NE 2018-12-31 2020-07-01 380000.00 nan \n",
"833874.NE 2018-12-31 2020-06-29 882100.00 nan \n",
"\n",
" ASSET_DISPOSAL_INCOME \\\n",
"code report_period appear_at_date \n",
"000400.SZ 2018-12-31 2019-03-29 0.00 \n",
"000558.SZ 2018-12-31 2019-04-26 -12902036.23 \n",
"000677.SZ 2018-12-31 2019-03-29 -1852690.97 \n",
"000731.SZ 2018-12-31 2019-04-16 1992627.87 \n",
"000752.SZ 2018-12-31 2019-05-16 0.00 \n",
"... ... \n",
"688039.SH 2018-12-31 2019-11-22 0.00 \n",
"688368.SH 2018-12-31 2019-09-17 0.00 \n",
"688396.SH 2018-12-31 2020-01-31 9434573.46 \n",
"831010.NE 2018-12-31 2020-07-01 -258845.78 \n",
"833874.NE 2018-12-31 2020-06-29 9554.96 \n",
"\n",
" CONTINUED_NET_PROFIT END_NET_PROFIT \\\n",
"code report_period appear_at_date \n",
"000400.SZ 2018-12-31 2019-03-29 2.737097e+08 0.0 \n",
"000558.SZ 2018-12-31 2019-04-26 -5.424955e+07 0.0 \n",
"000677.SZ 2018-12-31 2019-03-29 6.403690e+06 0.0 \n",
"000731.SZ 2018-12-31 2019-04-16 2.228619e+08 0.0 \n",
"000752.SZ 2018-12-31 2019-05-16 -3.830619e+08 0.0 \n",
"... ... ... \n",
"688039.SH 2018-12-31 2019-11-22 6.389806e+07 0.0 \n",
"688368.SH 2018-12-31 2019-09-17 0.000000e+00 0.0 \n",
"688396.SH 2018-12-31 2020-01-31 0.000000e+00 0.0 \n",
"831010.NE 2018-12-31 2020-07-01 4.129632e+07 0.0 \n",
"833874.NE 2018-12-31 2020-06-29 9.051358e+07 0.0 \n",
"\n",
" CREDIT_IMPAIRMENT_LOSS RD_EXPENSE \\\n",
"code report_period appear_at_date \n",
"000400.SZ 2018-12-31 2019-03-29 0.0 3.350267e+08 \n",
"000558.SZ 2018-12-31 2019-04-26 0.0 0.000000e+00 \n",
"000677.SZ 2018-12-31 2019-03-29 0.0 3.514984e+05 \n",
"000731.SZ 2018-12-31 2019-04-16 0.0 1.653546e+06 \n",
"000752.SZ 2018-12-31 2019-05-16 0.0 0.000000e+00 \n",
"... ... ... \n",
"688039.SH 2018-12-31 2019-11-22 0.0 3.660990e+07 \n",
"688368.SH 2018-12-31 2019-09-17 0.0 6.081719e+07 \n",
"688396.SH 2018-12-31 2020-01-31 0.0 4.497610e+08 \n",
"831010.NE 2018-12-31 2020-07-01 0.0 5.236440e+05 \n",
"833874.NE 2018-12-31 2020-06-29 0.0 1.092805e+07 \n",
"\n",
" STMNOTE_FINEXP FIN_EXP_INT_INC \\\n",
"code report_period appear_at_date \n",
"000400.SZ 2018-12-31 2019-03-29 45075829.77 0.0 \n",
"000558.SZ 2018-12-31 2019-04-26 39309311.59 0.0 \n",
"000677.SZ 2018-12-31 2019-03-29 5234360.37 0.0 \n",
"000731.SZ 2018-12-31 2019-04-16 46581902.65 0.0 \n",
"000752.SZ 2018-12-31 2019-05-16 0.00 0.0 \n",
"... ... ... \n",
"688039.SH 2018-12-31 2019-11-22 0.00 0.0 \n",
"688368.SH 2018-12-31 2019-09-17 0.00 0.0 \n",
"688396.SH 2018-12-31 2020-01-31 0.00 0.0 \n",
"831010.NE 2018-12-31 2020-07-01 254556.29 0.0 \n",
"833874.NE 2018-12-31 2020-06-29 0.00 0.0 \n",
"\n",
" TOT_OPER_COST2 \n",
"code report_period appear_at_date \n",
"000400.SZ 2018-12-31 2019-03-29 7.967406e+09 \n",
"000558.SZ 2018-12-31 2019-04-26 6.444387e+08 \n",
"000677.SZ 2018-12-31 2019-03-29 6.821367e+08 \n",
"000731.SZ 2018-12-31 2019-04-16 2.367904e+09 \n",
"000752.SZ 2018-12-31 2019-05-16 3.135966e+08 \n",
"... ... \n",
"688039.SH 2018-12-31 2019-11-22 1.511902e+08 \n",
"688368.SH 2018-12-31 2019-09-17 6.890894e+08 \n",
"688396.SH 2018-12-31 2020-01-31 5.796301e+09 \n",
"831010.NE 2018-12-31 2020-07-01 2.437095e+08 \n",
"833874.NE 2018-12-31 2020-06-29 1.021658e+08 \n",
"\n",
"[91 rows x 66 columns]"
]
},
"execution_count": 44,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#sess.run(\"\"\"\n",
"# is_common_ori = loadTable(\"dfs://pit_stock_ts\", \"is_common_ori\")\n",
"#\"\"\")\n",
"\n",
"# pit_report_period_at_date(table_name, date, report_period_list, code_partition_id)\n",
"sess.run(\"\"\"\n",
" select * from pit_at_date(\"is_common_ori\", 2021.03.14, [2018.12.31], 0) order by code\n",
"\"\"\").set_index(['code', 'report_period', 'appear_at_date'])"
]
},
{
"cell_type": "code",
"execution_count": 67,
"id": "4cd4cd6e-f34e-43a8-98de-c468a54d8081",
"metadata": {},
"outputs": [],
"source": [
"sess.run(\"\"\"\n",
" dropFunctionView('pit_col_at_date');\n",
"\"\"\")\n",
"\n",
"sess.run(\"\"\"\n",
"def pit_col_at_date(table_name, col_name, date, report_period_list, code_partition_id){\n",
"\tsource_table = loadTable(\"dfs://pit_stock_ts\", table_name);\n",
"\t\n",
"\tm_nDate = take(date, size(report_period_list));\n",
"\treport_period = report_period_list;\n",
"\t\n",
"\tquery_table = table(report_period, m_nDate);\n",
"\tquery_table_exp = select * from cj(query_table, select code from source_table where partition(code, code_partition_id) group by code map);\n",
"\t\n",
"\tcol_list = sqlCol(['code', 'report_period', 'appear_at_date', col_name]);\n",
" from_tbl = <ej(source_table, query_table_exp, `code`report_period)>;\n",
" where_conditions = [<partition(code, code_partition_id)>];\n",
" source_table_part = sql(select=col_list, from=from_tbl, where=where_conditions).eval();\n",
"\t\n",
"\treturn select source_table_part.* from aj(query_table_exp, source_table_part, `code`report_period`m_nDate, `code`report_period`appear_at_date) where not isNull(source_table_part.code)\n",
"}\n",
"\n",
"addFunctionView(pit_col_at_date);\n",
"\"\"\")"
]
},
{
"cell_type": "code",
"execution_count": 69,
"id": "943b760a-ab39-4291-8a93-81b3e38a70b7",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th>TOT_OPER_REV</th>\n",
" </tr>\n",
" <tr>\n",
" <th>code</th>\n",
" <th>report_period</th>\n",
" <th>appear_at_date</th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>000400.SZ</th>\n",
" <th>2019-09-30</th>\n",
" <th>2020-10-29</th>\n",
" <td>5.658881e+09</td>\n",
" </tr>\n",
" <tr>\n",
" <th>000558.SZ</th>\n",
" <th>2019-09-30</th>\n",
" <th>2020-10-29</th>\n",
" <td>8.322244e+07</td>\n",
" </tr>\n",
" <tr>\n",
" <th>000677.SZ</th>\n",
" <th>2019-09-30</th>\n",
" <th>2020-10-21</th>\n",
" <td>6.020088e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>000731.SZ</th>\n",
" <th>2019-09-30</th>\n",
" <th>2020-10-27</th>\n",
" <td>2.311672e+09</td>\n",
" </tr>\n",
" <tr>\n",
" <th>000752.SZ</th>\n",
" <th>2019-09-30</th>\n",
" <th>2020-10-29</th>\n",
" <td>2.330136e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <th>...</th>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>688039.SH</th>\n",
" <th>2019-09-30</th>\n",
" <th>2020-10-28</th>\n",
" <td>1.185143e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>688368.SH</th>\n",
" <th>2019-09-30</th>\n",
" <th>2020-10-28</th>\n",
" <td>6.139719e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>688396.SH</th>\n",
" <th>2019-09-30</th>\n",
" <th>2020-10-20</th>\n",
" <td>4.131915e+09</td>\n",
" </tr>\n",
" <tr>\n",
" <th>831010.NE</th>\n",
" <th>2019-09-30</th>\n",
" <th>2020-10-29</th>\n",
" <td>2.276040e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>833874.NE</th>\n",
" <th>2019-09-30</th>\n",
" <th>2020-10-26</th>\n",
" <td>1.303494e+08</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>91 rows × 1 columns</p>\n",
"</div>"
],
"text/plain": [
" TOT_OPER_REV\n",
"code report_period appear_at_date \n",
"000400.SZ 2019-09-30 2020-10-29 5.658881e+09\n",
"000558.SZ 2019-09-30 2020-10-29 8.322244e+07\n",
"000677.SZ 2019-09-30 2020-10-21 6.020088e+08\n",
"000731.SZ 2019-09-30 2020-10-27 2.311672e+09\n",
"000752.SZ 2019-09-30 2020-10-29 2.330136e+08\n",
"... ...\n",
"688039.SH 2019-09-30 2020-10-28 1.185143e+08\n",
"688368.SH 2019-09-30 2020-10-28 6.139719e+08\n",
"688396.SH 2019-09-30 2020-10-20 4.131915e+09\n",
"831010.NE 2019-09-30 2020-10-29 2.276040e+08\n",
"833874.NE 2019-09-30 2020-10-26 1.303494e+08\n",
"\n",
"[91 rows x 1 columns]"
]
},
"execution_count": 69,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sess.run(\"\"\"\n",
" select * from pit_col_at_date(\"is_common_adj\", \"TOT_OPER_REV\", 2021.03.14, [2019.09.30], 0) order by code\n",
"\"\"\").set_index(['code', 'report_period', 'appear_at_date'])"
]
},
{
"cell_type": "code",
"execution_count": 59,
"id": "2fea0f1e-5105-4d28-9c36-c5542a5389ba",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>code</th>\n",
" <th>report_period</th>\n",
" <th>appear_in_period</th>\n",
" <th>appear_at_date</th>\n",
" <th>TOT_OPER_REV</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>000400.SZ</td>\n",
" <td>2019-12-31</td>\n",
" <td>2019-12-31</td>\n",
" <td>2020-04-10</td>\n",
" <td>1.015608e+10</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>000558.SZ</td>\n",
" <td>2019-12-31</td>\n",
" <td>2019-12-31</td>\n",
" <td>2020-04-27</td>\n",
" <td>1.378479e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>000558.SZ</td>\n",
" <td>2019-12-31</td>\n",
" <td>2019-12-31</td>\n",
" <td>2020-08-25</td>\n",
" <td>1.378479e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>000677.SZ</td>\n",
" <td>2019-12-31</td>\n",
" <td>2019-12-31</td>\n",
" <td>2020-04-25</td>\n",
" <td>7.906742e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>000731.SZ</td>\n",
" <td>2019-12-31</td>\n",
" <td>2019-12-31</td>\n",
" <td>2020-04-24</td>\n",
" <td>2.929131e+09</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>109</th>\n",
" <td>688396.SH</td>\n",
" <td>2019-12-31</td>\n",
" <td>2019-12-31</td>\n",
" <td>2020-04-23</td>\n",
" <td>5.742784e+09</td>\n",
" </tr>\n",
" <tr>\n",
" <th>110</th>\n",
" <td>831010.NE</td>\n",
" <td>2019-12-31</td>\n",
" <td>2019-12-31</td>\n",
" <td>2020-04-13</td>\n",
" <td>3.552313e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>111</th>\n",
" <td>831010.NE</td>\n",
" <td>2019-12-31</td>\n",
" <td>2019-12-31</td>\n",
" <td>2020-07-01</td>\n",
" <td>3.552313e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>112</th>\n",
" <td>833874.NE</td>\n",
" <td>2019-12-31</td>\n",
" <td>2019-12-31</td>\n",
" <td>2020-03-18</td>\n",
" <td>1.785113e+08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>113</th>\n",
" <td>833874.NE</td>\n",
" <td>2019-12-31</td>\n",
" <td>2019-12-31</td>\n",
" <td>2020-06-29</td>\n",
" <td>1.785113e+08</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>114 rows × 5 columns</p>\n",
"</div>"
],
"text/plain": [
" code report_period appear_in_period appear_at_date TOT_OPER_REV\n",
"0 000400.SZ 2019-12-31 2019-12-31 2020-04-10 1.015608e+10\n",
"1 000558.SZ 2019-12-31 2019-12-31 2020-04-27 1.378479e+08\n",
"2 000558.SZ 2019-12-31 2019-12-31 2020-08-25 1.378479e+08\n",
"3 000677.SZ 2019-12-31 2019-12-31 2020-04-25 7.906742e+08\n",
"4 000731.SZ 2019-12-31 2019-12-31 2020-04-24 2.929131e+09\n",
".. ... ... ... ... ...\n",
"109 688396.SH 2019-12-31 2019-12-31 2020-04-23 5.742784e+09\n",
"110 831010.NE 2019-12-31 2019-12-31 2020-04-13 3.552313e+08\n",
"111 831010.NE 2019-12-31 2019-12-31 2020-07-01 3.552313e+08\n",
"112 833874.NE 2019-12-31 2019-12-31 2020-03-18 1.785113e+08\n",
"113 833874.NE 2019-12-31 2019-12-31 2020-06-29 1.785113e+08\n",
"\n",
"[114 rows x 5 columns]"
]
},
"execution_count": 59,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sess.run(\"\"\"\n",
" source_table = loadTable(\"dfs://pit_stock_ts\", \"is_common_ori\");\n",
" m_nDate = [2022.03.04]\n",
" report_period = [2019.12.31]\n",
"\tquery_table = table(report_period, m_nDate);\n",
"\tquery_table_exp = select * from cj(query_table, select code from source_table where partition(code, 0) group by code map);\n",
"\t\n",
" \n",
" col_list = sqlCol(['code', 'report_period', 'appear_in_period', 'appear_at_date', 'TOT_OPER_REV']);\n",
" from_tbl = <ej(source_table, query_table_exp, `code`report_period)>;\n",
" where_conditions = [<partition(code, 0)>];\n",
" source_table_part = sql(select=col_list, from=from_tbl, where=where_conditions).eval();\n",
"\tsource_table_part\n",
"\"\"\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3c246940-1ad6-414f-b461-2d8ca7cd87f1",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.13"
}
},
"nbformat": 4,
"nbformat_minor": 5
}