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.

174 lines
4.1 KiB

2 years ago
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "118641f9-96c3-4fd3-aea2-7ecdae17492e",
"metadata": {},
"outputs": [],
"source": [
"import dolphindb as ddb\n",
"\n",
"sess = ddb.session('localhost', 8848)\n",
"sess.login('admin', '123456')"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "44e3d35e-2e84-44fc-a3d2-00eaa0135460",
"metadata": {},
"outputs": [],
"source": [
"df = sess.run(\"\"\"\n",
" select code from loadTable(\"dfs://daily_stock_ts\", \"daily_kline\")\n",
" group by code order by code asc\n",
"\"\"\")\n",
"\n",
"df[\"entity_id\"] = df.index\n",
"df.set_index(\"code\", inplace=True)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "20a6066d-8efb-40fd-8a3b-3d848c8c0073",
"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>entity_id</th>\n",
" </tr>\n",
" <tr>\n",
" <th>code</th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>000001.SZ</th>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>000002.SZ</th>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>000004.SZ</th>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>000005.SZ</th>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>000006.SZ</th>\n",
" <td>4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>871970.NE</th>\n",
" <td>5010</td>\n",
" </tr>\n",
" <tr>\n",
" <th>871981.NE</th>\n",
" <td>5011</td>\n",
" </tr>\n",
" <tr>\n",
" <th>872925.NE</th>\n",
" <td>5012</td>\n",
" </tr>\n",
" <tr>\n",
" <th>873169.NE</th>\n",
" <td>5013</td>\n",
" </tr>\n",
" <tr>\n",
" <th>873223.NE</th>\n",
" <td>5014</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>5015 rows × 1 columns</p>\n",
"</div>"
],
"text/plain": [
" entity_id\n",
"code \n",
"000001.SZ 0\n",
"000002.SZ 1\n",
"000004.SZ 2\n",
"000005.SZ 3\n",
"000006.SZ 4\n",
"... ...\n",
"871970.NE 5010\n",
"871981.NE 5011\n",
"872925.NE 5012\n",
"873169.NE 5013\n",
"873223.NE 5014\n",
"\n",
"[5015 rows x 1 columns]"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "cc934d77-3cc1-458f-9e28-3f0715e9b87b",
"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
}