From 1c6aec05e93011a151e4622f5a3e19b32b99fbce Mon Sep 17 00:00:00 2001 From: flat35hd99 Date: Sat, 10 Aug 2024 19:42:45 +0900 Subject: [PATCH 1/4] =?UTF-8?q?30=E3=81=8F=E3=82=89=E3=81=84=E3=81=BE?= =?UTF-8?q?=E3=81=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker/doc/preprocess_knock_SQL.html | 22015 ++++++++++------------- docker/work/preprocess_knock_SQL.ipynb | 4264 ++++- 2 files changed, 13265 insertions(+), 13014 deletions(-) diff --git a/docker/doc/preprocess_knock_SQL.html b/docker/doc/preprocess_knock_SQL.html index b9140999..c0dd4112 100644 --- a/docker/doc/preprocess_knock_SQL.html +++ b/docker/doc/preprocess_knock_SQL.html @@ -1,13 +1,9 @@ - - - + + + preprocess_knock_SQL - - - - - - - - - - - - - - + + - - + + + + +
- - - - - - - diff --git a/docker/work/preprocess_knock_SQL.ipynb b/docker/work/preprocess_knock_SQL.ipynb index e6e392d6..e988f521 100644 --- a/docker/work/preprocess_knock_SQL.ipynb +++ b/docker/work/preprocess_knock_SQL.ipynb @@ -32,9 +32,18 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "There's a new jupysql version available (0.10.12), you're running 0.7.2. To upgrade: pip install jupysql --upgrade\n", + "Deploy FastAPI apps for free on Ploomber Cloud! Learn more: https://ploomber.io/s/signup\n" + ] + } + ], "source": [ "%load_ext sql\n", "import os\n", @@ -64,9 +73,42 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* postgresql://padawan:***@db:5432/dsdojo_db\n", + "1 rows affected.\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
sample
このように実行できます
" + ], + "text/plain": [ + "[('このように実行できます',)]" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "%%sql\n", "SELECT 'このように実行できます' AS sample;" @@ -89,11 +131,171 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* postgresql://padawan:***@db:5432/dsdojo_db\n", + "10 rows affected.\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
sales_ymdsales_epochstore_cdreceipt_noreceipt_sub_nocustomer_idproduct_cdquantityamount
201811031541203200S140061121CS006214000001P0703050121158
201811181542499200S1300811322CS008415000097P070701017181
201707121499817600S1402811021CS028414000014P0601010051170
201902051549324800S1404211321ZZ000000000000P050301001125
201808211534809600S1402511022CS025415000050P060102007190
201906051559692800S1300311121CS003515000195P0501020021138
201812051543968000S1402411022CS024514000042P080101005130
201909221569110400S1404011021CS040415000178P0705010041128
201705041493856000S1302011122ZZ000000000000P0713020101770
201910101570665600S1402711021CS027514000015P0711010031680
" + ], + "text/plain": [ + "[(20181103, 1541203200, 'S14006', 112, 1, 'CS006214000001', 'P070305012', 1, 158),\n", + " (20181118, 1542499200, 'S13008', 1132, 2, 'CS008415000097', 'P070701017', 1, 81),\n", + " (20170712, 1499817600, 'S14028', 1102, 1, 'CS028414000014', 'P060101005', 1, 170),\n", + " (20190205, 1549324800, 'S14042', 1132, 1, 'ZZ000000000000', 'P050301001', 1, 25),\n", + " (20180821, 1534809600, 'S14025', 1102, 2, 'CS025415000050', 'P060102007', 1, 90),\n", + " (20190605, 1559692800, 'S13003', 1112, 1, 'CS003515000195', 'P050102002', 1, 138),\n", + " (20181205, 1543968000, 'S14024', 1102, 2, 'CS024514000042', 'P080101005', 1, 30),\n", + " (20190922, 1569110400, 'S14040', 1102, 1, 'CS040415000178', 'P070501004', 1, 128),\n", + " (20170504, 1493856000, 'S13020', 1112, 2, 'ZZ000000000000', 'P071302010', 1, 770),\n", + " (20191010, 1570665600, 'S14027', 1102, 1, 'CS027514000015', 'P071101003', 1, 680)]" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "%%sql\n" + "%%sql\n", + "SELECT *\n", + "FROM receipt\n", + "LIMIT 10;" ] }, { @@ -106,11 +308,116 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* postgresql://padawan:***@db:5432/dsdojo_db\n", + "10 rows affected.\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
sales_ymdcustomer_idproduct_cdamount
20181103CS006214000001P070305012158
20181118CS008415000097P07070101781
20170712CS028414000014P060101005170
20190205ZZ000000000000P05030100125
20180821CS025415000050P06010200790
20190605CS003515000195P050102002138
20181205CS024514000042P08010100530
20190922CS040415000178P070501004128
20170504ZZ000000000000P071302010770
20191010CS027514000015P071101003680
" + ], + "text/plain": [ + "[(20181103, 'CS006214000001', 'P070305012', 158),\n", + " (20181118, 'CS008415000097', 'P070701017', 81),\n", + " (20170712, 'CS028414000014', 'P060101005', 170),\n", + " (20190205, 'ZZ000000000000', 'P050301001', 25),\n", + " (20180821, 'CS025415000050', 'P060102007', 90),\n", + " (20190605, 'CS003515000195', 'P050102002', 138),\n", + " (20181205, 'CS024514000042', 'P080101005', 30),\n", + " (20190922, 'CS040415000178', 'P070501004', 128),\n", + " (20170504, 'ZZ000000000000', 'P071302010', 770),\n", + " (20191010, 'CS027514000015', 'P071101003', 680)]" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "%%sql\n" + "%%sql\n", + "SELECT sales_ymd, customer_id, product_cd, amount\n", + "FROM receipt\n", + "LIMIT 10;" ] }, { @@ -123,11 +430,116 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* postgresql://padawan:***@db:5432/dsdojo_db\n", + "10 rows affected.\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
sales_datecustomer_idproduct_cdamount
20181103CS006214000001P070305012158
20181118CS008415000097P07070101781
20170712CS028414000014P060101005170
20190205ZZ000000000000P05030100125
20180821CS025415000050P06010200790
20190605CS003515000195P050102002138
20181205CS024514000042P08010100530
20190922CS040415000178P070501004128
20170504ZZ000000000000P071302010770
20191010CS027514000015P071101003680
" + ], + "text/plain": [ + "[(20181103, 'CS006214000001', 'P070305012', 158),\n", + " (20181118, 'CS008415000097', 'P070701017', 81),\n", + " (20170712, 'CS028414000014', 'P060101005', 170),\n", + " (20190205, 'ZZ000000000000', 'P050301001', 25),\n", + " (20180821, 'CS025415000050', 'P060102007', 90),\n", + " (20190605, 'CS003515000195', 'P050102002', 138),\n", + " (20181205, 'CS024514000042', 'P080101005', 30),\n", + " (20190922, 'CS040415000178', 'P070501004', 128),\n", + " (20170504, 'ZZ000000000000', 'P071302010', 770),\n", + " (20191010, 'CS027514000015', 'P071101003', 680)]" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "%%sql\n" + "%%sql\n", + "SELECT sales_ymd AS sales_date, customer_id, product_cd, amount\n", + "FROM receipt\n", + "LIMIT 10;" ] }, { @@ -141,11 +553,130 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* postgresql://padawan:***@db:5432/dsdojo_db\n", + "12 rows affected.\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
sales_ymdcustomer_idproduct_cdamount
20180911CS018205000001P0714010122200
20180414CS018205000001P060104007600
20170614CS018205000001P050206001990
20170614CS018205000001P060702015108
20190216CS018205000001P071005024102
20180414CS018205000001P071101002278
20190226CS018205000001P070902035168
20190924CS018205000001P060805001495
20190226CS018205000001P0714010202200
20180911CS018205000001P0714010051100
20190216CS018205000001P040101002218
20190924CS018205000001P091503001280
" + ], + "text/plain": [ + "[(20180911, 'CS018205000001', 'P071401012', 2200),\n", + " (20180414, 'CS018205000001', 'P060104007', 600),\n", + " (20170614, 'CS018205000001', 'P050206001', 990),\n", + " (20170614, 'CS018205000001', 'P060702015', 108),\n", + " (20190216, 'CS018205000001', 'P071005024', 102),\n", + " (20180414, 'CS018205000001', 'P071101002', 278),\n", + " (20190226, 'CS018205000001', 'P070902035', 168),\n", + " (20190924, 'CS018205000001', 'P060805001', 495),\n", + " (20190226, 'CS018205000001', 'P071401020', 2200),\n", + " (20180911, 'CS018205000001', 'P071401005', 1100),\n", + " (20190216, 'CS018205000001', 'P040101002', 218),\n", + " (20190924, 'CS018205000001', 'P091503001', 280)]" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "%%sql\n" + "%%sql\n", + "SELECT sales_ymd, customer_id, product_cd, amount\n", + "FROM receipt\n", + "WHERE customer_id = 'CS018205000001';" ] }, { @@ -160,11 +691,67 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* postgresql://padawan:***@db:5432/dsdojo_db\n", + "3 rows affected.\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
sales_ymdcustomer_idproduct_cdamount
20180911CS018205000001P0714010122200
20190226CS018205000001P0714010202200
20180911CS018205000001P0714010051100
" + ], + "text/plain": [ + "[(20180911, 'CS018205000001', 'P071401012', 2200),\n", + " (20190226, 'CS018205000001', 'P071401020', 2200),\n", + " (20180911, 'CS018205000001', 'P071401005', 1100)]" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "%%sql\n" + "%%sql\n", + "SELECT sales_ymd, customer_id, product_cd, amount\n", + "FROM receipt\n", + "WHERE customer_id = 'CS018205000001' AND amount >= 1000;" ] }, { @@ -179,11 +766,87 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* postgresql://padawan:***@db:5432/dsdojo_db\n", + "5 rows affected.\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
sales_ymdcustomer_idproduct_cdquantityamount
20180911CS018205000001P07140101212200
20180414CS018205000001P0601040076600
20170614CS018205000001P0502060015990
20190226CS018205000001P07140102012200
20180911CS018205000001P07140100511100
" + ], + "text/plain": [ + "[(20180911, 'CS018205000001', 'P071401012', 1, 2200),\n", + " (20180414, 'CS018205000001', 'P060104007', 6, 600),\n", + " (20170614, 'CS018205000001', 'P050206001', 5, 990),\n", + " (20190226, 'CS018205000001', 'P071401020', 1, 2200),\n", + " (20180911, 'CS018205000001', 'P071401005', 1, 1100)]" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "%%sql\n" + "%%sql\n", + "SELECT sales_ymd, customer_id, product_cd, quantity, amount\n", + "FROM receipt\n", + "WHERE customer_id = 'CS018205000001' AND (amount >= 1000 OR quantity >= 5);" ] }, { @@ -198,11 +861,53 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* postgresql://padawan:***@db:5432/dsdojo_db\n", + "1 rows affected.\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
sales_ymdcustomer_idproduct_cdamount
20180911CS018205000001P0714010051100
" + ], + "text/plain": [ + "[(20180911, 'CS018205000001', 'P071401005', 1100)]" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "%%sql\n" + "%%sql\n", + "SELECT sales_ymd, customer_id, product_cd, amount\n", + "FROM receipt\n", + "WHERE customer_id = 'CS018205000001' AND (amount >= 1000 AND amount <= 2000);" ] }, { @@ -217,11 +922,130 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* postgresql://padawan:***@db:5432/dsdojo_db\n", + "12 rows affected.\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
sales_ymdcustomer_idproduct_cdamount
20180911CS018205000001P0714010122200
20180414CS018205000001P060104007600
20170614CS018205000001P050206001990
20170614CS018205000001P060702015108
20190216CS018205000001P071005024102
20180414CS018205000001P071101002278
20190226CS018205000001P070902035168
20190924CS018205000001P060805001495
20190226CS018205000001P0714010202200
20180911CS018205000001P0714010051100
20190216CS018205000001P040101002218
20190924CS018205000001P091503001280
" + ], + "text/plain": [ + "[(20180911, 'CS018205000001', 'P071401012', 2200),\n", + " (20180414, 'CS018205000001', 'P060104007', 600),\n", + " (20170614, 'CS018205000001', 'P050206001', 990),\n", + " (20170614, 'CS018205000001', 'P060702015', 108),\n", + " (20190216, 'CS018205000001', 'P071005024', 102),\n", + " (20180414, 'CS018205000001', 'P071101002', 278),\n", + " (20190226, 'CS018205000001', 'P070902035', 168),\n", + " (20190924, 'CS018205000001', 'P060805001', 495),\n", + " (20190226, 'CS018205000001', 'P071401020', 2200),\n", + " (20180911, 'CS018205000001', 'P071401005', 1100),\n", + " (20190216, 'CS018205000001', 'P040101002', 218),\n", + " (20190924, 'CS018205000001', 'P091503001', 280)]" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "%%sql\n" + "%%sql\n", + "SELECT sales_ymd, customer_id, product_cd, amount\n", + "FROM receipt\n", + "WHERE customer_id = 'CS018205000001' AND product_cd != 'P071401019'" ] }, { @@ -236,11 +1060,89 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* postgresql://padawan:***@db:5432/dsdojo_db\n", + "3 rows affected.\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
store_cdstore_nameprefecture_cdprefectureaddressaddress_kanatel_nolongitudelatitudefloor_area
S14046北山田店14神奈川県神奈川県横浜市都筑区北山田一丁目カナガワケンヨコハマシツヅキクキタヤマタイッチョウメ045-123-4049139.591635.56189831.0
S14011日吉本町店14神奈川県神奈川県横浜市港北区日吉本町四丁目カナガワケンヨコハマシコウホククヒヨシホンチョウヨンチョウメ045-123-4033139.631635.54655890.0
S12013習志野店12千葉県千葉県習志野市芝園一丁目チバケンナラシノシシバゾノイッチョウメ047-123-4002140.02235.66122808.0
" + ], + "text/plain": [ + "[('S14046', '北山田店', '14', '神奈川県', '神奈川県横浜市都筑区北山田一丁目', 'カナガワケンヨコハマシツヅキクキタヤマタイッチョウメ', '045-123-4049', Decimal('139.5916'), Decimal('35.56189'), Decimal('831.0')),\n", + " ('S14011', '日吉本町店', '14', '神奈川県', '神奈川県横浜市港北区日吉本町四丁目', 'カナガワケンヨコハマシコウホククヒヨシホンチョウヨンチョウメ', '045-123-4033', Decimal('139.6316'), Decimal('35.54655'), Decimal('890.0')),\n", + " ('S12013', '習志野店', '12', '千葉県', '千葉県習志野市芝園一丁目', 'チバケンナラシノシシバゾノイッチョウメ', '047-123-4002', Decimal('140.022'), Decimal('35.66122'), Decimal('808.0'))]" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "%%sql\n" + "%%sql\n", + "SELECT * FROM store WHERE prefecture_cd != '13' AND floor_area <= 900" ] }, { @@ -253,11 +1155,182 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 19, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* postgresql://padawan:***@db:5432/dsdojo_db\n", + "10 rows affected.\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
store_cdstore_nameprefecture_cdprefectureaddressaddress_kanatel_nolongitudelatitudefloor_area
S14010菊名店14神奈川県神奈川県横浜市港北区菊名一丁目カナガワケンヨコハマシコウホククキクナイッチョウメ045-123-4032139.632635.500491732.0
S14033阿久和店14神奈川県神奈川県横浜市瀬谷区阿久和西一丁目カナガワケンヨコハマシセヤクアクワニシイッチョウメ045-123-4043139.496135.459181495.0
S14036相模原中央店14神奈川県神奈川県相模原市中央二丁目カナガワケンサガミハラシチュウオウニチョウメ042-123-4045139.371635.573271679.0
S14040長津田店14神奈川県神奈川県横浜市緑区長津田みなみ台五丁目カナガワケンヨコハマシミドリクナガツタミナミダイゴチョウメ045-123-4046139.499435.523981548.0
S14050阿久和西店14神奈川県神奈川県横浜市瀬谷区阿久和西一丁目カナガワケンヨコハマシセヤクアクワニシイッチョウメ045-123-4053139.496135.459181830.0
S14028二ツ橋店14神奈川県神奈川県横浜市瀬谷区二ツ橋町カナガワケンヨコハマシセヤクフタツバシチョウ045-123-4042139.496335.463041574.0
S14012本牧和田店14神奈川県神奈川県横浜市中区本牧和田カナガワケンヨコハマシナカクホンモクワダ045-123-4034139.658235.421561341.0
S14046北山田店14神奈川県神奈川県横浜市都筑区北山田一丁目カナガワケンヨコハマシツヅキクキタヤマタイッチョウメ045-123-4049139.591635.56189831.0
S14022逗子店14神奈川県神奈川県逗子市逗子一丁目カナガワケンズシシズシイッチョウメ046-123-4036139.578935.296421838.0
S14011日吉本町店14神奈川県神奈川県横浜市港北区日吉本町四丁目カナガワケンヨコハマシコウホククヒヨシホンチョウヨンチョウメ045-123-4033139.631635.54655890.0
" + ], + "text/plain": [ + "[('S14010', '菊名店', '14', '神奈川県', '神奈川県横浜市港北区菊名一丁目', 'カナガワケンヨコハマシコウホククキクナイッチョウメ', '045-123-4032', Decimal('139.6326'), Decimal('35.50049'), Decimal('1732.0')),\n", + " ('S14033', '阿久和店', '14', '神奈川県', '神奈川県横浜市瀬谷区阿久和西一丁目', 'カナガワケンヨコハマシセヤクアクワニシイッチョウメ', '045-123-4043', Decimal('139.4961'), Decimal('35.45918'), Decimal('1495.0')),\n", + " ('S14036', '相模原中央店', '14', '神奈川県', '神奈川県相模原市中央二丁目', 'カナガワケンサガミハラシチュウオウニチョウメ', '042-123-4045', Decimal('139.3716'), Decimal('35.57327'), Decimal('1679.0')),\n", + " ('S14040', '長津田店', '14', '神奈川県', '神奈川県横浜市緑区長津田みなみ台五丁目', 'カナガワケンヨコハマシミドリクナガツタミナミダイゴチョウメ', '045-123-4046', Decimal('139.4994'), Decimal('35.52398'), Decimal('1548.0')),\n", + " ('S14050', '阿久和西店', '14', '神奈川県', '神奈川県横浜市瀬谷区阿久和西一丁目', 'カナガワケンヨコハマシセヤクアクワニシイッチョウメ', '045-123-4053', Decimal('139.4961'), Decimal('35.45918'), Decimal('1830.0')),\n", + " ('S14028', '二ツ橋店', '14', '神奈川県', '神奈川県横浜市瀬谷区二ツ橋町', 'カナガワケンヨコハマシセヤクフタツバシチョウ', '045-123-4042', Decimal('139.4963'), Decimal('35.46304'), Decimal('1574.0')),\n", + " ('S14012', '本牧和田店', '14', '神奈川県', '神奈川県横浜市中区本牧和田', 'カナガワケンヨコハマシナカクホンモクワダ', '045-123-4034', Decimal('139.6582'), Decimal('35.42156'), Decimal('1341.0')),\n", + " ('S14046', '北山田店', '14', '神奈川県', '神奈川県横浜市都筑区北山田一丁目', 'カナガワケンヨコハマシツヅキクキタヤマタイッチョウメ', '045-123-4049', Decimal('139.5916'), Decimal('35.56189'), Decimal('831.0')),\n", + " ('S14022', '逗子店', '14', '神奈川県', '神奈川県逗子市逗子一丁目', 'カナガワケンズシシズシイッチョウメ', '046-123-4036', Decimal('139.5789'), Decimal('35.29642'), Decimal('1838.0')),\n", + " ('S14011', '日吉本町店', '14', '神奈川県', '神奈川県横浜市港北区日吉本町四丁目', 'カナガワケンヨコハマシコウホククヒヨシホンチョウヨンチョウメ', '045-123-4033', Decimal('139.6316'), Decimal('35.54655'), Decimal('890.0'))]" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "%%sql\n" + "%%sql\n", + "SELECT * FROM store\n", + "WHERE store_cd LIKE 'S14%'\n", + "LIMIT 10;" ] }, { @@ -270,11 +1343,193 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 20, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* postgresql://padawan:***@db:5432/dsdojo_db\n", + "10 rows affected.\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
customer_idcustomer_namegender_cdgenderbirth_dayagepostal_cdaddressapplication_store_cdapplication_datestatus_cd
CS037613000071六角 雅彦9不明1952-04-0166136-0076東京都江東区南砂**********S13037201504140-00000000-0
CS028811000001堀井 かおり1女性1933-03-2786245-0016神奈川県横浜市泉区和泉町**********S14028201601150-00000000-0
CS040412000191川井 郁恵1女性1977-01-0542226-0021神奈川県横浜市緑区北八朔町**********S14040201511011-20091025-4
CS028314000011小菅 あおい1女性1983-11-2635246-0038神奈川県横浜市瀬谷区宮沢**********S14028201511231-20080426-5
CS039212000051藤島 恵梨香1女性1997-02-0322166-0001東京都杉並区阿佐谷北**********S13039201711211-20100215-4
CS015412000111松居 奈月1女性1972-10-0446136-0071東京都江東区亀戸**********S13015201506290-00000000-0
CS004702000041野島 洋0男性1943-08-2475176-0022東京都練馬区向山**********S13004201702180-00000000-0
CS041515000001栗田 千夏1女性1967-01-0252206-0001東京都多摩市和田**********S1304120160422E-20100803-F
CS029313000221北条 ひかり1女性1987-06-1931279-0011千葉県浦安市美浜**********S12029201808100-00000000-0
CS034312000071望月 奈央1女性1980-09-2038213-0026神奈川県川崎市高津区久末**********S14034201601060-00000000-0
" + ], + "text/plain": [ + "[('CS037613000071', '六角 雅彦', '9', '不明', datetime.date(1952, 4, 1), 66, '136-0076', '東京都江東区南砂**********', 'S13037', '20150414', '0-00000000-0'),\n", + " ('CS028811000001', '堀井 かおり', '1', '女性', datetime.date(1933, 3, 27), 86, '245-0016', '神奈川県横浜市泉区和泉町**********', 'S14028', '20160115', '0-00000000-0'),\n", + " ('CS040412000191', '川井 郁恵', '1', '女性', datetime.date(1977, 1, 5), 42, '226-0021', '神奈川県横浜市緑区北八朔町**********', 'S14040', '20151101', '1-20091025-4'),\n", + " ('CS028314000011', '小菅 あおい', '1', '女性', datetime.date(1983, 11, 26), 35, '246-0038', '神奈川県横浜市瀬谷区宮沢**********', 'S14028', '20151123', '1-20080426-5'),\n", + " ('CS039212000051', '藤島 恵梨香', '1', '女性', datetime.date(1997, 2, 3), 22, '166-0001', '東京都杉並区阿佐谷北**********', 'S13039', '20171121', '1-20100215-4'),\n", + " ('CS015412000111', '松居 奈月', '1', '女性', datetime.date(1972, 10, 4), 46, '136-0071', '東京都江東区亀戸**********', 'S13015', '20150629', '0-00000000-0'),\n", + " ('CS004702000041', '野島 洋', '0', '男性', datetime.date(1943, 8, 24), 75, '176-0022', '東京都練馬区向山**********', 'S13004', '20170218', '0-00000000-0'),\n", + " ('CS041515000001', '栗田 千夏', '1', '女性', datetime.date(1967, 1, 2), 52, '206-0001', '東京都多摩市和田**********', 'S13041', '20160422', 'E-20100803-F'),\n", + " ('CS029313000221', '北条 ひかり', '1', '女性', datetime.date(1987, 6, 19), 31, '279-0011', '千葉県浦安市美浜**********', 'S12029', '20180810', '0-00000000-0'),\n", + " ('CS034312000071', '望月 奈央', '1', '女性', datetime.date(1980, 9, 20), 38, '213-0026', '神奈川県川崎市高津区久末**********', 'S14034', '20160106', '0-00000000-0')]" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "%%sql\n" + "%%sql\n", + "SELECT * FROM customer\n", + "WHERE customer_id LIKE '%1'\n", + "LIMIT 10;" ] }, { @@ -287,11 +1542,194 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 21, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* postgresql://padawan:***@db:5432/dsdojo_db\n", + "11 rows affected.\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
store_cdstore_nameprefecture_cdprefectureaddressaddress_kanatel_nolongitudelatitudefloor_area
S14010菊名店14神奈川県神奈川県横浜市港北区菊名一丁目カナガワケンヨコハマシコウホククキクナイッチョウメ045-123-4032139.632635.500491732.0
S14033阿久和店14神奈川県神奈川県横浜市瀬谷区阿久和西一丁目カナガワケンヨコハマシセヤクアクワニシイッチョウメ045-123-4043139.496135.459181495.0
S14040長津田店14神奈川県神奈川県横浜市緑区長津田みなみ台五丁目カナガワケンヨコハマシミドリクナガツタミナミダイゴチョウメ045-123-4046139.499435.523981548.0
S14050阿久和西店14神奈川県神奈川県横浜市瀬谷区阿久和西一丁目カナガワケンヨコハマシセヤクアクワニシイッチョウメ045-123-4053139.496135.459181830.0
S14028二ツ橋店14神奈川県神奈川県横浜市瀬谷区二ツ橋町カナガワケンヨコハマシセヤクフタツバシチョウ045-123-4042139.496335.463041574.0
S14012本牧和田店14神奈川県神奈川県横浜市中区本牧和田カナガワケンヨコハマシナカクホンモクワダ045-123-4034139.658235.421561341.0
S14046北山田店14神奈川県神奈川県横浜市都筑区北山田一丁目カナガワケンヨコハマシツヅキクキタヤマタイッチョウメ045-123-4049139.591635.56189831.0
S14011日吉本町店14神奈川県神奈川県横浜市港北区日吉本町四丁目カナガワケンヨコハマシコウホククヒヨシホンチョウヨンチョウメ045-123-4033139.631635.54655890.0
S14048中川中央店14神奈川県神奈川県横浜市都筑区中川中央二丁目カナガワケンヨコハマシツヅキクナカガワチュウオウニチョウメ045-123-4051139.575835.549121657.0
S14042新山下店14神奈川県神奈川県横浜市中区新山下二丁目カナガワケンヨコハマシナカクシンヤマシタニチョウメ045-123-4047139.659335.438941044.0
S14006葛が谷店14神奈川県神奈川県横浜市都筑区葛が谷カナガワケンヨコハマシツヅキククズガヤ045-123-4031139.563335.535731886.0
" + ], + "text/plain": [ + "[('S14010', '菊名店', '14', '神奈川県', '神奈川県横浜市港北区菊名一丁目', 'カナガワケンヨコハマシコウホククキクナイッチョウメ', '045-123-4032', Decimal('139.6326'), Decimal('35.50049'), Decimal('1732.0')),\n", + " ('S14033', '阿久和店', '14', '神奈川県', '神奈川県横浜市瀬谷区阿久和西一丁目', 'カナガワケンヨコハマシセヤクアクワニシイッチョウメ', '045-123-4043', Decimal('139.4961'), Decimal('35.45918'), Decimal('1495.0')),\n", + " ('S14040', '長津田店', '14', '神奈川県', '神奈川県横浜市緑区長津田みなみ台五丁目', 'カナガワケンヨコハマシミドリクナガツタミナミダイゴチョウメ', '045-123-4046', Decimal('139.4994'), Decimal('35.52398'), Decimal('1548.0')),\n", + " ('S14050', '阿久和西店', '14', '神奈川県', '神奈川県横浜市瀬谷区阿久和西一丁目', 'カナガワケンヨコハマシセヤクアクワニシイッチョウメ', '045-123-4053', Decimal('139.4961'), Decimal('35.45918'), Decimal('1830.0')),\n", + " ('S14028', '二ツ橋店', '14', '神奈川県', '神奈川県横浜市瀬谷区二ツ橋町', 'カナガワケンヨコハマシセヤクフタツバシチョウ', '045-123-4042', Decimal('139.4963'), Decimal('35.46304'), Decimal('1574.0')),\n", + " ('S14012', '本牧和田店', '14', '神奈川県', '神奈川県横浜市中区本牧和田', 'カナガワケンヨコハマシナカクホンモクワダ', '045-123-4034', Decimal('139.6582'), Decimal('35.42156'), Decimal('1341.0')),\n", + " ('S14046', '北山田店', '14', '神奈川県', '神奈川県横浜市都筑区北山田一丁目', 'カナガワケンヨコハマシツヅキクキタヤマタイッチョウメ', '045-123-4049', Decimal('139.5916'), Decimal('35.56189'), Decimal('831.0')),\n", + " ('S14011', '日吉本町店', '14', '神奈川県', '神奈川県横浜市港北区日吉本町四丁目', 'カナガワケンヨコハマシコウホククヒヨシホンチョウヨンチョウメ', '045-123-4033', Decimal('139.6316'), Decimal('35.54655'), Decimal('890.0')),\n", + " ('S14048', '中川中央店', '14', '神奈川県', '神奈川県横浜市都筑区中川中央二丁目', 'カナガワケンヨコハマシツヅキクナカガワチュウオウニチョウメ', '045-123-4051', Decimal('139.5758'), Decimal('35.54912'), Decimal('1657.0')),\n", + " ('S14042', '新山下店', '14', '神奈川県', '神奈川県横浜市中区新山下二丁目', 'カナガワケンヨコハマシナカクシンヤマシタニチョウメ', '045-123-4047', Decimal('139.6593'), Decimal('35.43894'), Decimal('1044.0')),\n", + " ('S14006', '葛が谷店', '14', '神奈川県', '神奈川県横浜市都筑区葛が谷', 'カナガワケンヨコハマシツヅキククズガヤ', '045-123-4031', Decimal('139.5633'), Decimal('35.53573'), Decimal('1886.0'))]" + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "%%sql\n" + "%%sql\n", + "SELECT * FROM store\n", + "WHERE address LIKE '%横浜市%';" ] }, { @@ -304,11 +1742,193 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 25, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* postgresql://padawan:***@db:5432/dsdojo_db\n", + "10 rows affected.\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
customer_idcustomer_namegender_cdgenderbirth_dayagepostal_cdaddressapplication_store_cdapplication_datestatus_cd
CS031415000172宇多田 貴美子1女性1976-10-0442151-0053東京都渋谷区代々木**********S1303120150529D-20100325-C
CS015414000103奥野 陽子1女性1977-08-0941136-0073東京都江東区北砂**********S1301520150722B-20100609-B
CS011215000048芦田 沙耶1女性1992-02-0127223-0062神奈川県横浜市港北区日吉本町**********S1401120150228C-20100421-9
CS029415000023梅田 里穂1女性1976-01-1743279-0043千葉県浦安市富士見**********S1202920150610D-20100918-E
CS035415000029寺沢 真希9不明1977-09-2741158-0096東京都世田谷区玉川台**********S1303520141220F-20101029-F
CS031415000106宇野 由美子1女性1970-02-2649151-0053東京都渋谷区代々木**********S1303120150201F-20100511-E
CS029215000025石倉 美帆1女性1993-09-2825279-0022千葉県浦安市今川**********S1202920150708B-20100820-C
CS033605000005猪股 雄太0男性1955-12-0563246-0031神奈川県横浜市瀬谷区瀬谷**********S1403320150425F-20100917-E
CS033415000229板垣 菜々美1女性1977-11-0741246-0021神奈川県横浜市瀬谷区二ツ橋町**********S1403320150712F-20100326-E
CS008415000145黒谷 麻緒1女性1977-06-2741157-0067東京都世田谷区喜多見**********S1300820150829F-20100622-F
" + ], + "text/plain": [ + "[('CS031415000172', '宇多田 貴美子', '1', '女性', datetime.date(1976, 10, 4), 42, '151-0053', '東京都渋谷区代々木**********', 'S13031', '20150529', 'D-20100325-C'),\n", + " ('CS015414000103', '奥野 陽子', '1', '女性', datetime.date(1977, 8, 9), 41, '136-0073', '東京都江東区北砂**********', 'S13015', '20150722', 'B-20100609-B'),\n", + " ('CS011215000048', '芦田 沙耶', '1', '女性', datetime.date(1992, 2, 1), 27, '223-0062', '神奈川県横浜市港北区日吉本町**********', 'S14011', '20150228', 'C-20100421-9'),\n", + " ('CS029415000023', '梅田 里穂', '1', '女性', datetime.date(1976, 1, 17), 43, '279-0043', '千葉県浦安市富士見**********', 'S12029', '20150610', 'D-20100918-E'),\n", + " ('CS035415000029', '寺沢 真希', '9', '不明', datetime.date(1977, 9, 27), 41, '158-0096', '東京都世田谷区玉川台**********', 'S13035', '20141220', 'F-20101029-F'),\n", + " ('CS031415000106', '宇野 由美子', '1', '女性', datetime.date(1970, 2, 26), 49, '151-0053', '東京都渋谷区代々木**********', 'S13031', '20150201', 'F-20100511-E'),\n", + " ('CS029215000025', '石倉 美帆', '1', '女性', datetime.date(1993, 9, 28), 25, '279-0022', '千葉県浦安市今川**********', 'S12029', '20150708', 'B-20100820-C'),\n", + " ('CS033605000005', '猪股 雄太', '0', '男性', datetime.date(1955, 12, 5), 63, '246-0031', '神奈川県横浜市瀬谷区瀬谷**********', 'S14033', '20150425', 'F-20100917-E'),\n", + " ('CS033415000229', '板垣 菜々美', '1', '女性', datetime.date(1977, 11, 7), 41, '246-0021', '神奈川県横浜市瀬谷区二ツ橋町**********', 'S14033', '20150712', 'F-20100326-E'),\n", + " ('CS008415000145', '黒谷 麻緒', '1', '女性', datetime.date(1977, 6, 27), 41, '157-0067', '東京都世田谷区喜多見**********', 'S13008', '20150829', 'F-20100622-F')]" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "%%sql\n" + "%%sql\n", + "SELECT * FROM customer\n", + "WHERE status_cd ~ '^[A-F]'\n", + "LIMIT 10;" ] }, { @@ -321,11 +1941,193 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 26, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* postgresql://padawan:***@db:5432/dsdojo_db\n", + "10 rows affected.\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
customer_idcustomer_namegender_cdgenderbirth_dayagepostal_cdaddressapplication_store_cdapplication_datestatus_cd
CS001215000145田崎 美紀1女性1995-03-2924144-0055東京都大田区仲六郷**********S13001201706056-20090929-2
CS033513000180安斎 遥1女性1962-07-1156241-0823神奈川県横浜市旭区善部町**********S14033201507286-20080506-5
CS011215000048芦田 沙耶1女性1992-02-0127223-0062神奈川県横浜市港北区日吉本町**********S1401120150228C-20100421-9
CS040412000191川井 郁恵1女性1977-01-0542226-0021神奈川県横浜市緑区北八朔町**********S14040201511011-20091025-4
CS009315000023皆川 文世1女性1980-04-1538154-0012東京都世田谷区駒沢**********S13009201503195-20080322-1
CS015315000033福士 璃奈子1女性1983-03-1736135-0043東京都江東区塩浜**********S13015201410244-20080219-3
CS023513000066神戸 そら1女性1961-12-1757210-0005神奈川県川崎市川崎区東田町**********S14023201509155-20100524-9
CS035513000134市川 美帆1女性1960-03-2759156-0053東京都世田谷区桜**********S13035201502278-20100711-9
CS001515000263高松 夏空1女性1962-11-0956144-0051東京都大田区西蒲田**********S13001201608121-20100804-1
CS040314000027鶴田 きみまろ9不明1986-03-2633226-0027神奈川県横浜市緑区長津田**********S14040201501222-20080426-4
" + ], + "text/plain": [ + "[('CS001215000145', '田崎 美紀', '1', '女性', datetime.date(1995, 3, 29), 24, '144-0055', '東京都大田区仲六郷**********', 'S13001', '20170605', '6-20090929-2'),\n", + " ('CS033513000180', '安斎 遥', '1', '女性', datetime.date(1962, 7, 11), 56, '241-0823', '神奈川県横浜市旭区善部町**********', 'S14033', '20150728', '6-20080506-5'),\n", + " ('CS011215000048', '芦田 沙耶', '1', '女性', datetime.date(1992, 2, 1), 27, '223-0062', '神奈川県横浜市港北区日吉本町**********', 'S14011', '20150228', 'C-20100421-9'),\n", + " ('CS040412000191', '川井 郁恵', '1', '女性', datetime.date(1977, 1, 5), 42, '226-0021', '神奈川県横浜市緑区北八朔町**********', 'S14040', '20151101', '1-20091025-4'),\n", + " ('CS009315000023', '皆川 文世', '1', '女性', datetime.date(1980, 4, 15), 38, '154-0012', '東京都世田谷区駒沢**********', 'S13009', '20150319', '5-20080322-1'),\n", + " ('CS015315000033', '福士 璃奈子', '1', '女性', datetime.date(1983, 3, 17), 36, '135-0043', '東京都江東区塩浜**********', 'S13015', '20141024', '4-20080219-3'),\n", + " ('CS023513000066', '神戸 そら', '1', '女性', datetime.date(1961, 12, 17), 57, '210-0005', '神奈川県川崎市川崎区東田町**********', 'S14023', '20150915', '5-20100524-9'),\n", + " ('CS035513000134', '市川 美帆', '1', '女性', datetime.date(1960, 3, 27), 59, '156-0053', '東京都世田谷区桜**********', 'S13035', '20150227', '8-20100711-9'),\n", + " ('CS001515000263', '高松 夏空', '1', '女性', datetime.date(1962, 11, 9), 56, '144-0051', '東京都大田区西蒲田**********', 'S13001', '20160812', '1-20100804-1'),\n", + " ('CS040314000027', '鶴田 きみまろ', '9', '不明', datetime.date(1986, 3, 26), 33, '226-0027', '神奈川県横浜市緑区長津田**********', 'S14040', '20150122', '2-20080426-4')]" + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "%%sql\n" + "%%sql\n", + "SELECT * FROM customer\n", + "WHERE status_cd ~ '[1-9]$'\n", + "LIMIT 10;" ] }, { @@ -338,11 +2140,193 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 27, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* postgresql://padawan:***@db:5432/dsdojo_db\n", + "10 rows affected.\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
customer_idcustomer_namegender_cdgenderbirth_dayagepostal_cdaddressapplication_store_cdapplication_datestatus_cd
CS011215000048芦田 沙耶1女性1992-02-0127223-0062神奈川県横浜市港北区日吉本町**********S1401120150228C-20100421-9
CS022513000105島村 貴美子1女性1962-03-1257249-0002神奈川県逗子市山の根**********S1402220150320A-20091115-7
CS001515000096水野 陽子9不明1960-11-2958144-0053東京都大田区蒲田本町**********S1300120150614A-20100724-7
CS013615000053西脇 季衣1女性1953-10-1865261-0026千葉県千葉市美浜区幕張西**********S1201320150128B-20100329-6
CS020412000161小宮 薫1女性1974-05-2144174-0042東京都板橋区東坂下**********S1302020150822B-20081021-3
CS001215000097竹中 あさみ1女性1990-07-2528146-0095東京都大田区多摩川**********S1300120170315A-20100211-2
CS035212000007内村 恵梨香1女性1990-12-0428152-0023東京都目黒区八雲**********S1303520151013B-20101018-6
CS002515000386野田 コウ1女性1963-05-3055185-0013東京都国分寺市西恋ケ窪**********S1300220160410C-20100127-8
CS001615000372稲垣 寿々花1女性1956-10-2962144-0035東京都大田区南蒲田**********S1300120170403A-20100104-1
CS032512000121松井 知世1女性1962-09-0456210-0011神奈川県川崎市川崎区富士見**********S1303220150727A-20100103-5
" + ], + "text/plain": [ + "[('CS011215000048', '芦田 沙耶', '1', '女性', datetime.date(1992, 2, 1), 27, '223-0062', '神奈川県横浜市港北区日吉本町**********', 'S14011', '20150228', 'C-20100421-9'),\n", + " ('CS022513000105', '島村 貴美子', '1', '女性', datetime.date(1962, 3, 12), 57, '249-0002', '神奈川県逗子市山の根**********', 'S14022', '20150320', 'A-20091115-7'),\n", + " ('CS001515000096', '水野 陽子', '9', '不明', datetime.date(1960, 11, 29), 58, '144-0053', '東京都大田区蒲田本町**********', 'S13001', '20150614', 'A-20100724-7'),\n", + " ('CS013615000053', '西脇 季衣', '1', '女性', datetime.date(1953, 10, 18), 65, '261-0026', '千葉県千葉市美浜区幕張西**********', 'S12013', '20150128', 'B-20100329-6'),\n", + " ('CS020412000161', '小宮 薫', '1', '女性', datetime.date(1974, 5, 21), 44, '174-0042', '東京都板橋区東坂下**********', 'S13020', '20150822', 'B-20081021-3'),\n", + " ('CS001215000097', '竹中 あさみ', '1', '女性', datetime.date(1990, 7, 25), 28, '146-0095', '東京都大田区多摩川**********', 'S13001', '20170315', 'A-20100211-2'),\n", + " ('CS035212000007', '内村 恵梨香', '1', '女性', datetime.date(1990, 12, 4), 28, '152-0023', '東京都目黒区八雲**********', 'S13035', '20151013', 'B-20101018-6'),\n", + " ('CS002515000386', '野田 コウ', '1', '女性', datetime.date(1963, 5, 30), 55, '185-0013', '東京都国分寺市西恋ケ窪**********', 'S13002', '20160410', 'C-20100127-8'),\n", + " ('CS001615000372', '稲垣 寿々花', '1', '女性', datetime.date(1956, 10, 29), 62, '144-0035', '東京都大田区南蒲田**********', 'S13001', '20170403', 'A-20100104-1'),\n", + " ('CS032512000121', '松井 知世', '1', '女性', datetime.date(1962, 9, 4), 56, '210-0011', '神奈川県川崎市川崎区富士見**********', 'S13032', '20150727', 'A-20100103-5')]" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "%%sql\n" + "%%sql\n", + "SELECT * FROM customer\n", + "WHERE status_cd ~ '^[A-F].*[1-9]$'\n", + "LIMIT 10;" ] }, { @@ -355,11 +2339,493 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 28, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* postgresql://padawan:***@db:5432/dsdojo_db\n", + "34 rows affected.\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
store_cdstore_nameprefecture_cdprefectureaddressaddress_kanatel_nolongitudelatitudefloor_area
S12014千草台店12千葉県千葉県千葉市稲毛区千草台一丁目チバケンチバシイナゲクチグサダイイッチョウメ043-123-4003140.11835.635591698.0
S13002国分寺店13東京都東京都国分寺市本多二丁目トウキョウトコクブンジシホンダニチョウメ042-123-4008139.480235.705661735.0
S14010菊名店14神奈川県神奈川県横浜市港北区菊名一丁目カナガワケンヨコハマシコウホククキクナイッチョウメ045-123-4032139.632635.500491732.0
S14033阿久和店14神奈川県神奈川県横浜市瀬谷区阿久和西一丁目カナガワケンヨコハマシセヤクアクワニシイッチョウメ045-123-4043139.496135.459181495.0
S14036相模原中央店14神奈川県神奈川県相模原市中央二丁目カナガワケンサガミハラシチュウオウニチョウメ042-123-4045139.371635.573271679.0
S14040長津田店14神奈川県神奈川県横浜市緑区長津田みなみ台五丁目カナガワケンヨコハマシミドリクナガツタミナミダイゴチョウメ045-123-4046139.499435.523981548.0
S14050阿久和西店14神奈川県神奈川県横浜市瀬谷区阿久和西一丁目カナガワケンヨコハマシセヤクアクワニシイッチョウメ045-123-4053139.496135.459181830.0
S13052森野店13東京都東京都町田市森野三丁目トウキョウトマチダシモリノサンチョウメ042-123-4030139.438335.552931087.0
S14028二ツ橋店14神奈川県神奈川県横浜市瀬谷区二ツ橋町カナガワケンヨコハマシセヤクフタツバシチョウ045-123-4042139.496335.463041574.0
S14012本牧和田店14神奈川県神奈川県横浜市中区本牧和田カナガワケンヨコハマシナカクホンモクワダ045-123-4034139.658235.421561341.0
S14046北山田店14神奈川県神奈川県横浜市都筑区北山田一丁目カナガワケンヨコハマシツヅキクキタヤマタイッチョウメ045-123-4049139.591635.56189831.0
S14022逗子店14神奈川県神奈川県逗子市逗子一丁目カナガワケンズシシズシイッチョウメ046-123-4036139.578935.296421838.0
S14011日吉本町店14神奈川県神奈川県横浜市港北区日吉本町四丁目カナガワケンヨコハマシコウホククヒヨシホンチョウヨンチョウメ045-123-4033139.631635.54655890.0
S13016小金井店13東京都東京都小金井市本町一丁目トウキョウトコガネイシホンチョウイッチョウメ042-123-4015139.509435.700181399.0
S14034川崎野川店14神奈川県神奈川県川崎市宮前区野川カナガワケンカワサキシミヤマエクノガワ044-123-4044139.599835.576931318.0
S14048中川中央店14神奈川県神奈川県横浜市都筑区中川中央二丁目カナガワケンヨコハマシツヅキクナカガワチュウオウニチョウメ045-123-4051139.575835.549121657.0
S12007佐倉店12千葉県千葉県佐倉市上志津チバケンサクラシカミシヅ043-123-4001140.145235.718721895.0
S14026辻堂西海岸店14神奈川県神奈川県藤沢市辻堂西海岸二丁目カナガワケンフジサワシツジドウニシカイガンニチョウメ046-123-4040139.446635.324641732.0
S13041八王子店13東京都東京都八王子市大塚トウキョウトハチオウジシオオツカ042-123-4026139.423535.63787810.0
S14049川崎大師店14神奈川県神奈川県川崎市川崎区中瀬三丁目カナガワケンカワサキシカワサキクナカゼサンチョウメ044-123-4052139.732735.53759962.0
S14023川崎店14神奈川県神奈川県川崎市川崎区本町二丁目カナガワケンカワサキシカワサキクホンチョウニチョウメ044-123-4037139.702835.535991804.0
S13018清瀬店13東京都東京都清瀬市松山一丁目トウキョウトキヨセシマツヤマイッチョウメ042-123-4017139.517835.768851220.0
S14027南藤沢店14神奈川県神奈川県藤沢市南藤沢カナガワケンフジサワシミナミフジサワ046-123-4041139.489635.337621521.0
S14021伊勢原店14神奈川県神奈川県伊勢原市伊勢原四丁目カナガワケンイセハラシイセハラヨンチョウメ046-123-4035139.312935.40169962.0
S14047相模原店14神奈川県神奈川県相模原市千代田六丁目カナガワケンサガミハラシチヨダロクチョウメ042-123-4050139.374835.559591047.0
S12013習志野店12千葉県千葉県習志野市芝園一丁目チバケンナラシノシシバゾノイッチョウメ047-123-4002140.02235.66122808.0
S14042新山下店14神奈川県神奈川県横浜市中区新山下二丁目カナガワケンヨコハマシナカクシンヤマシタニチョウメ045-123-4047139.659335.438941044.0
S12030八幡店12千葉県千葉県市川市八幡三丁目チバケンイチカワシヤワタサンチョウメ047-123-4005139.92435.723181162.0
S14025大和店14神奈川県神奈川県大和市下和田カナガワケンヤマトシシモワダ046-123-4039139.46835.434141011.0
S14045厚木店14神奈川県神奈川県厚木市中町二丁目カナガワケンアツギシナカチョウニチョウメ046-123-4048139.365135.44182980.0
S12029東野店12千葉県千葉県浦安市東野一丁目チバケンウラヤスシヒガシノイッチョウメ047-123-4004139.896835.650861101.0
S12053高洲店12千葉県千葉県浦安市高洲五丁目チバケンウラヤスシタカスゴチョウメ047-123-4006139.917635.637551555.0
S14024三田店14神奈川県神奈川県川崎市多摩区三田四丁目カナガワケンカワサキシタマクミタヨンチョウメ044-123-4038139.542435.6077972.0
S14006葛が谷店14神奈川県神奈川県横浜市都筑区葛が谷カナガワケンヨコハマシツヅキククズガヤ045-123-4031139.563335.535731886.0
" + ], + "text/plain": [ + "[('S12014', '千草台店', '12', '千葉県', '千葉県千葉市稲毛区千草台一丁目', 'チバケンチバシイナゲクチグサダイイッチョウメ', '043-123-4003', Decimal('140.118'), Decimal('35.63559'), Decimal('1698.0')),\n", + " ('S13002', '国分寺店', '13', '東京都', '東京都国分寺市本多二丁目', 'トウキョウトコクブンジシホンダニチョウメ', '042-123-4008', Decimal('139.4802'), Decimal('35.70566'), Decimal('1735.0')),\n", + " ('S14010', '菊名店', '14', '神奈川県', '神奈川県横浜市港北区菊名一丁目', 'カナガワケンヨコハマシコウホククキクナイッチョウメ', '045-123-4032', Decimal('139.6326'), Decimal('35.50049'), Decimal('1732.0')),\n", + " ('S14033', '阿久和店', '14', '神奈川県', '神奈川県横浜市瀬谷区阿久和西一丁目', 'カナガワケンヨコハマシセヤクアクワニシイッチョウメ', '045-123-4043', Decimal('139.4961'), Decimal('35.45918'), Decimal('1495.0')),\n", + " ('S14036', '相模原中央店', '14', '神奈川県', '神奈川県相模原市中央二丁目', 'カナガワケンサガミハラシチュウオウニチョウメ', '042-123-4045', Decimal('139.3716'), Decimal('35.57327'), Decimal('1679.0')),\n", + " ('S14040', '長津田店', '14', '神奈川県', '神奈川県横浜市緑区長津田みなみ台五丁目', 'カナガワケンヨコハマシミドリクナガツタミナミダイゴチョウメ', '045-123-4046', Decimal('139.4994'), Decimal('35.52398'), Decimal('1548.0')),\n", + " ('S14050', '阿久和西店', '14', '神奈川県', '神奈川県横浜市瀬谷区阿久和西一丁目', 'カナガワケンヨコハマシセヤクアクワニシイッチョウメ', '045-123-4053', Decimal('139.4961'), Decimal('35.45918'), Decimal('1830.0')),\n", + " ('S13052', '森野店', '13', '東京都', '東京都町田市森野三丁目', 'トウキョウトマチダシモリノサンチョウメ', '042-123-4030', Decimal('139.4383'), Decimal('35.55293'), Decimal('1087.0')),\n", + " ('S14028', '二ツ橋店', '14', '神奈川県', '神奈川県横浜市瀬谷区二ツ橋町', 'カナガワケンヨコハマシセヤクフタツバシチョウ', '045-123-4042', Decimal('139.4963'), Decimal('35.46304'), Decimal('1574.0')),\n", + " ('S14012', '本牧和田店', '14', '神奈川県', '神奈川県横浜市中区本牧和田', 'カナガワケンヨコハマシナカクホンモクワダ', '045-123-4034', Decimal('139.6582'), Decimal('35.42156'), Decimal('1341.0')),\n", + " ('S14046', '北山田店', '14', '神奈川県', '神奈川県横浜市都筑区北山田一丁目', 'カナガワケンヨコハマシツヅキクキタヤマタイッチョウメ', '045-123-4049', Decimal('139.5916'), Decimal('35.56189'), Decimal('831.0')),\n", + " ('S14022', '逗子店', '14', '神奈川県', '神奈川県逗子市逗子一丁目', 'カナガワケンズシシズシイッチョウメ', '046-123-4036', Decimal('139.5789'), Decimal('35.29642'), Decimal('1838.0')),\n", + " ('S14011', '日吉本町店', '14', '神奈川県', '神奈川県横浜市港北区日吉本町四丁目', 'カナガワケンヨコハマシコウホククヒヨシホンチョウヨンチョウメ', '045-123-4033', Decimal('139.6316'), Decimal('35.54655'), Decimal('890.0')),\n", + " ('S13016', '小金井店', '13', '東京都', '東京都小金井市本町一丁目', 'トウキョウトコガネイシホンチョウイッチョウメ', '042-123-4015', Decimal('139.5094'), Decimal('35.70018'), Decimal('1399.0')),\n", + " ('S14034', '川崎野川店', '14', '神奈川県', '神奈川県川崎市宮前区野川', 'カナガワケンカワサキシミヤマエクノガワ', '044-123-4044', Decimal('139.5998'), Decimal('35.57693'), Decimal('1318.0')),\n", + " ('S14048', '中川中央店', '14', '神奈川県', '神奈川県横浜市都筑区中川中央二丁目', 'カナガワケンヨコハマシツヅキクナカガワチュウオウニチョウメ', '045-123-4051', Decimal('139.5758'), Decimal('35.54912'), Decimal('1657.0')),\n", + " ('S12007', '佐倉店', '12', '千葉県', '千葉県佐倉市上志津', 'チバケンサクラシカミシヅ', '043-123-4001', Decimal('140.1452'), Decimal('35.71872'), Decimal('1895.0')),\n", + " ('S14026', '辻堂西海岸店', '14', '神奈川県', '神奈川県藤沢市辻堂西海岸二丁目', 'カナガワケンフジサワシツジドウニシカイガンニチョウメ', '046-123-4040', Decimal('139.4466'), Decimal('35.32464'), Decimal('1732.0')),\n", + " ('S13041', '八王子店', '13', '東京都', '東京都八王子市大塚', 'トウキョウトハチオウジシオオツカ', '042-123-4026', Decimal('139.4235'), Decimal('35.63787'), Decimal('810.0')),\n", + " ('S14049', '川崎大師店', '14', '神奈川県', '神奈川県川崎市川崎区中瀬三丁目', 'カナガワケンカワサキシカワサキクナカゼサンチョウメ', '044-123-4052', Decimal('139.7327'), Decimal('35.53759'), Decimal('962.0')),\n", + " ('S14023', '川崎店', '14', '神奈川県', '神奈川県川崎市川崎区本町二丁目', 'カナガワケンカワサキシカワサキクホンチョウニチョウメ', '044-123-4037', Decimal('139.7028'), Decimal('35.53599'), Decimal('1804.0')),\n", + " ('S13018', '清瀬店', '13', '東京都', '東京都清瀬市松山一丁目', 'トウキョウトキヨセシマツヤマイッチョウメ', '042-123-4017', Decimal('139.5178'), Decimal('35.76885'), Decimal('1220.0')),\n", + " ('S14027', '南藤沢店', '14', '神奈川県', '神奈川県藤沢市南藤沢', 'カナガワケンフジサワシミナミフジサワ', '046-123-4041', Decimal('139.4896'), Decimal('35.33762'), Decimal('1521.0')),\n", + " ('S14021', '伊勢原店', '14', '神奈川県', '神奈川県伊勢原市伊勢原四丁目', 'カナガワケンイセハラシイセハラヨンチョウメ', '046-123-4035', Decimal('139.3129'), Decimal('35.40169'), Decimal('962.0')),\n", + " ('S14047', '相模原店', '14', '神奈川県', '神奈川県相模原市千代田六丁目', 'カナガワケンサガミハラシチヨダロクチョウメ', '042-123-4050', Decimal('139.3748'), Decimal('35.55959'), Decimal('1047.0')),\n", + " ('S12013', '習志野店', '12', '千葉県', '千葉県習志野市芝園一丁目', 'チバケンナラシノシシバゾノイッチョウメ', '047-123-4002', Decimal('140.022'), Decimal('35.66122'), Decimal('808.0')),\n", + " ('S14042', '新山下店', '14', '神奈川県', '神奈川県横浜市中区新山下二丁目', 'カナガワケンヨコハマシナカクシンヤマシタニチョウメ', '045-123-4047', Decimal('139.6593'), Decimal('35.43894'), Decimal('1044.0')),\n", + " ('S12030', '八幡店', '12', '千葉県', '千葉県市川市八幡三丁目', 'チバケンイチカワシヤワタサンチョウメ', '047-123-4005', Decimal('139.924'), Decimal('35.72318'), Decimal('1162.0')),\n", + " ('S14025', '大和店', '14', '神奈川県', '神奈川県大和市下和田', 'カナガワケンヤマトシシモワダ', '046-123-4039', Decimal('139.468'), Decimal('35.43414'), Decimal('1011.0')),\n", + " ('S14045', '厚木店', '14', '神奈川県', '神奈川県厚木市中町二丁目', 'カナガワケンアツギシナカチョウニチョウメ', '046-123-4048', Decimal('139.3651'), Decimal('35.44182'), Decimal('980.0')),\n", + " ('S12029', '東野店', '12', '千葉県', '千葉県浦安市東野一丁目', 'チバケンウラヤスシヒガシノイッチョウメ', '047-123-4004', Decimal('139.8968'), Decimal('35.65086'), Decimal('1101.0')),\n", + " ('S12053', '高洲店', '12', '千葉県', '千葉県浦安市高洲五丁目', 'チバケンウラヤスシタカスゴチョウメ', '047-123-4006', Decimal('139.9176'), Decimal('35.63755'), Decimal('1555.0')),\n", + " ('S14024', '三田店', '14', '神奈川県', '神奈川県川崎市多摩区三田四丁目', 'カナガワケンカワサキシタマクミタヨンチョウメ', '044-123-4038', Decimal('139.5424'), Decimal('35.6077'), Decimal('972.0')),\n", + " ('S14006', '葛が谷店', '14', '神奈川県', '神奈川県横浜市都筑区葛が谷', 'カナガワケンヨコハマシツヅキククズガヤ', '045-123-4031', Decimal('139.5633'), Decimal('35.53573'), Decimal('1886.0'))]" + ] + }, + "execution_count": 28, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "%%sql\n" + "%%sql\n", + "SELECT * FROM store\n", + "WHERE tel_no ~ '[0-9]{3}-[0-9]{3}-[0-9]{4}'" ] }, { @@ -372,11 +2838,194 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 31, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* postgresql://padawan:***@db:5432/dsdojo_db\n", + "10 rows affected.\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
customer_idcustomer_namegender_cdgenderbirth_dayagepostal_cdaddressapplication_store_cdapplication_datestatus_cd
CS003813000014村山 菜々美1女性1928-11-2690182-0007東京都調布市菊野台**********S13003201602140-00000000-0
CS026813000004吉村 朝陽1女性1928-12-1490251-0043神奈川県藤沢市辻堂元町**********S14026201507230-00000000-0
CS018811000003熊沢 美里1女性1929-01-0790204-0004東京都清瀬市野塩**********S13018201504030-00000000-0
CS027803000004内村 拓郎0男性1929-01-1290251-0031神奈川県藤沢市鵠沼藤が谷**********S14027201512270-00000000-0
CS013801000003天野 拓郎0男性1929-01-1590274-0824千葉県船橋市前原東**********S12013201601200-00000000-0
CS001814000022鶴田 里穂1女性1929-01-2890144-0045東京都大田区南六郷**********S1300120161012A-20090415-7
CS016815000002山元 美紀1女性1929-02-2290184-0005東京都小金井市桜町**********S1301620150629C-20090923-C
CS009815000003中田 里穂1女性1929-04-0889154-0014東京都世田谷区新町**********S1300920150421D-20091021-E
CS012813000013宇野 南朋1女性1929-04-0989231-0806神奈川県横浜市中区本牧町**********S14012201507120-00000000-0
CS005813000015金谷 恵梨香1女性1929-04-0989165-0032東京都中野区鷺宮**********S13005201505060-00000000-0
" + ], + "text/plain": [ + "[('CS003813000014', '村山 菜々美', '1', '女性', datetime.date(1928, 11, 26), 90, '182-0007', '東京都調布市菊野台**********', 'S13003', '20160214', '0-00000000-0'),\n", + " ('CS026813000004', '吉村 朝陽', '1', '女性', datetime.date(1928, 12, 14), 90, '251-0043', '神奈川県藤沢市辻堂元町**********', 'S14026', '20150723', '0-00000000-0'),\n", + " ('CS018811000003', '熊沢 美里', '1', '女性', datetime.date(1929, 1, 7), 90, '204-0004', '東京都清瀬市野塩**********', 'S13018', '20150403', '0-00000000-0'),\n", + " ('CS027803000004', '内村 拓郎', '0', '男性', datetime.date(1929, 1, 12), 90, '251-0031', '神奈川県藤沢市鵠沼藤が谷**********', 'S14027', '20151227', '0-00000000-0'),\n", + " ('CS013801000003', '天野 拓郎', '0', '男性', datetime.date(1929, 1, 15), 90, '274-0824', '千葉県船橋市前原東**********', 'S12013', '20160120', '0-00000000-0'),\n", + " ('CS001814000022', '鶴田 里穂', '1', '女性', datetime.date(1929, 1, 28), 90, '144-0045', '東京都大田区南六郷**********', 'S13001', '20161012', 'A-20090415-7'),\n", + " ('CS016815000002', '山元 美紀', '1', '女性', datetime.date(1929, 2, 22), 90, '184-0005', '東京都小金井市桜町**********', 'S13016', '20150629', 'C-20090923-C'),\n", + " ('CS009815000003', '中田 里穂', '1', '女性', datetime.date(1929, 4, 8), 89, '154-0014', '東京都世田谷区新町**********', 'S13009', '20150421', 'D-20091021-E'),\n", + " ('CS012813000013', '宇野 南朋', '1', '女性', datetime.date(1929, 4, 9), 89, '231-0806', '神奈川県横浜市中区本牧町**********', 'S14012', '20150712', '0-00000000-0'),\n", + " ('CS005813000015', '金谷 恵梨香', '1', '女性', datetime.date(1929, 4, 9), 89, '165-0032', '東京都中野区鷺宮**********', 'S13005', '20150506', '0-00000000-0')]" + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "%%sql\n" + "%%sql\n", + "SELECT *\n", + "FROM customer\n", + "ORDER BY birth_day ASC\n", + "LIMIT 10;" ] }, { @@ -389,11 +3038,194 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 32, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* postgresql://padawan:***@db:5432/dsdojo_db\n", + "10 rows affected.\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
customer_idcustomer_namegender_cdgenderbirth_dayagepostal_cdaddressapplication_store_cdapplication_datestatus_cd
CS035114000004大村 美里1女性2007-11-2511156-0053東京都世田谷区桜**********S13035201506196-20091205-6
CS022103000002福山 はじめ9不明2007-10-0211249-0006神奈川県逗子市逗子**********S14022201609090-00000000-0
CS002113000009柴田 真悠子1女性2007-09-1711184-0014東京都小金井市貫井南町**********S13002201603040-00000000-0
CS004115000014松井 京子1女性2007-08-0911165-0031東京都中野区上鷺宮**********S13004201611201-20081231-1
CS002114000010山内 遥1女性2007-06-0311184-0015東京都小金井市貫井北町**********S13002201609206-20100510-1
CS025115000002小柳 夏希1女性2007-04-1811245-0018神奈川県横浜市泉区上飯田町**********S1402520160116D-20100913-D
CS002113000025広末 まなみ1女性2007-03-3012184-0015東京都小金井市貫井北町**********S13002201710300-00000000-0
CS033112000003長野 美紀1女性2007-03-2212245-0051神奈川県横浜市戸塚区名瀬町**********S14033201506060-00000000-0
CS007115000006福岡 瞬1女性2007-03-1012285-0845千葉県佐倉市西志津**********S1200720151118F-20101016-F
CS014113000008矢口 莉緒1女性2007-03-0512260-0041千葉県千葉市中央区東千葉**********S12014201506223-20091108-6
" + ], + "text/plain": [ + "[('CS035114000004', '大村 美里', '1', '女性', datetime.date(2007, 11, 25), 11, '156-0053', '東京都世田谷区桜**********', 'S13035', '20150619', '6-20091205-6'),\n", + " ('CS022103000002', '福山 はじめ', '9', '不明', datetime.date(2007, 10, 2), 11, '249-0006', '神奈川県逗子市逗子**********', 'S14022', '20160909', '0-00000000-0'),\n", + " ('CS002113000009', '柴田 真悠子', '1', '女性', datetime.date(2007, 9, 17), 11, '184-0014', '東京都小金井市貫井南町**********', 'S13002', '20160304', '0-00000000-0'),\n", + " ('CS004115000014', '松井 京子', '1', '女性', datetime.date(2007, 8, 9), 11, '165-0031', '東京都中野区上鷺宮**********', 'S13004', '20161120', '1-20081231-1'),\n", + " ('CS002114000010', '山内 遥', '1', '女性', datetime.date(2007, 6, 3), 11, '184-0015', '東京都小金井市貫井北町**********', 'S13002', '20160920', '6-20100510-1'),\n", + " ('CS025115000002', '小柳 夏希', '1', '女性', datetime.date(2007, 4, 18), 11, '245-0018', '神奈川県横浜市泉区上飯田町**********', 'S14025', '20160116', 'D-20100913-D'),\n", + " ('CS002113000025', '広末 まなみ', '1', '女性', datetime.date(2007, 3, 30), 12, '184-0015', '東京都小金井市貫井北町**********', 'S13002', '20171030', '0-00000000-0'),\n", + " ('CS033112000003', '長野 美紀', '1', '女性', datetime.date(2007, 3, 22), 12, '245-0051', '神奈川県横浜市戸塚区名瀬町**********', 'S14033', '20150606', '0-00000000-0'),\n", + " ('CS007115000006', '福岡 瞬', '1', '女性', datetime.date(2007, 3, 10), 12, '285-0845', '千葉県佐倉市西志津**********', 'S12007', '20151118', 'F-20101016-F'),\n", + " ('CS014113000008', '矢口 莉緒', '1', '女性', datetime.date(2007, 3, 5), 12, '260-0041', '千葉県千葉市中央区東千葉**********', 'S12014', '20150622', '3-20091108-6')]" + ] + }, + "execution_count": 32, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "%%sql\n" + "%%sql\n", + "SELECT *\n", + "FROM customer\n", + "ORDER BY birth_day DESC\n", + "LIMIT 10;" ] }, { @@ -406,11 +3238,108 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 37, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* postgresql://padawan:***@db:5432/dsdojo_db\n", + "10 rows affected.\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
customer_idamountamount_rank
CS011415000006109251
ZZ00000000000068002
CS02860500000257803
ZZ00000000000054804
CS01551500003454804
ZZ00000000000054804
ZZ00000000000054407
CS02151500008954407
CS02041400008152809
CS00141200016052809
" + ], + "text/plain": [ + "[('CS011415000006', 10925, 1),\n", + " ('ZZ000000000000', 6800, 2),\n", + " ('CS028605000002', 5780, 3),\n", + " ('ZZ000000000000', 5480, 4),\n", + " ('CS015515000034', 5480, 4),\n", + " ('ZZ000000000000', 5480, 4),\n", + " ('ZZ000000000000', 5440, 7),\n", + " ('CS021515000089', 5440, 7),\n", + " ('CS020414000081', 5280, 9),\n", + " ('CS001412000160', 5280, 9)]" + ] + }, + "execution_count": 37, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "%%sql\n" + "%%sql\n", + "SELECT customer_id, amount, RANK() OVER (\n", + " ORDER BY amount DESC\n", + ") AS amount_rank\n", + "FROM receipt\n", + "ORDER BY amount DESC\n", + "LIMIT 10;" ] }, { @@ -423,11 +3352,108 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 38, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* postgresql://padawan:***@db:5432/dsdojo_db\n", + "10 rows affected.\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
customer_idamountamount_rank
CS011415000006109251
ZZ00000000000068002
CS02860500000257803
ZZ00000000000054804
ZZ00000000000054805
CS01551500003454806
CS02151500008954407
ZZ00000000000054408
CS02741500013352809
CS040415000200528010
" + ], + "text/plain": [ + "[('CS011415000006', 10925, 1),\n", + " ('ZZ000000000000', 6800, 2),\n", + " ('CS028605000002', 5780, 3),\n", + " ('ZZ000000000000', 5480, 4),\n", + " ('ZZ000000000000', 5480, 5),\n", + " ('CS015515000034', 5480, 6),\n", + " ('CS021515000089', 5440, 7),\n", + " ('ZZ000000000000', 5440, 8),\n", + " ('CS027415000133', 5280, 9),\n", + " ('CS040415000200', 5280, 10)]" + ] + }, + "execution_count": 38, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "%%sql\n" + "%%sql\n", + "SELECT customer_id, amount, ROW_NUMBER() OVER (\n", + " ORDER BY amount DESC\n", + ") AS amount_rank\n", + "FROM receipt\n", + "ORDER BY amount DESC\n", + "LIMIT 10;" ] }, { @@ -440,11 +3466,46 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 39, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* postgresql://padawan:***@db:5432/dsdojo_db\n", + "1 rows affected.\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
count
104681
" + ], + "text/plain": [ + "[(104681,)]" + ] + }, + "execution_count": 39, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "%%sql\n" + "%%sql\n", + "SELECT count(*)\n", + "FROM receipt;" ] }, { @@ -457,11 +3518,46 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 46, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* postgresql://padawan:***@db:5432/dsdojo_db\n", + "1 rows affected.\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
count
8307
" + ], + "text/plain": [ + "[(8307,)]" + ] + }, + "execution_count": 46, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "%%sql\n" + "%%sql\n", + "SELECT count(DISTINCT customer_id)\n", + "FROM receipt;" ] }, { @@ -474,11 +3570,304 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 48, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* postgresql://padawan:***@db:5432/dsdojo_db\n", + "52 rows affected.\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
sumsum_1
6387612099
7482212376
5878951881
100314250
7937732432
7145502303
8088702486
6513282047
8278332541
6118881981
4126461354
7642942197
7861452458
4584841398
7278212340
5346891935
7793732390
7088842337
7251672358
6995112231
7128392284
8119362347
7276302258
7555812394
7158692219
234276769
7206002412
7363232417
7282662233
8245372503
7903612290
7808732248
8092882491
230808788
167090580
7059682336
7875132425
5207641729
7253182282
7947412555
6930872344
6844022403
7905012491
6536812024
7018582233
6298762004
3383291041
8057242434
7905352562
7963832383
107452354
203694635
" + ], + "text/plain": [ + "[(638761, 2099),\n", + " (748221, 2376),\n", + " (587895, 1881),\n", + " (100314, 250),\n", + " (793773, 2432),\n", + " (714550, 2303),\n", + " (808870, 2486),\n", + " (651328, 2047),\n", + " (827833, 2541),\n", + " (611888, 1981),\n", + " (412646, 1354),\n", + " (764294, 2197),\n", + " (786145, 2458),\n", + " (458484, 1398),\n", + " (727821, 2340),\n", + " (534689, 1935),\n", + " (779373, 2390),\n", + " (708884, 2337),\n", + " (725167, 2358),\n", + " (699511, 2231),\n", + " (712839, 2284),\n", + " (811936, 2347),\n", + " (727630, 2258),\n", + " (755581, 2394),\n", + " (715869, 2219),\n", + " (234276, 769),\n", + " (720600, 2412),\n", + " (736323, 2417),\n", + " (728266, 2233),\n", + " (824537, 2503),\n", + " (790361, 2290),\n", + " (780873, 2248),\n", + " (809288, 2491),\n", + " (230808, 788),\n", + " (167090, 580),\n", + " (705968, 2336),\n", + " (787513, 2425),\n", + " (520764, 1729),\n", + " (725318, 2282),\n", + " (794741, 2555),\n", + " (693087, 2344),\n", + " (684402, 2403),\n", + " (790501, 2491),\n", + " (653681, 2024),\n", + " (701858, 2233),\n", + " (629876, 2004),\n", + " (338329, 1041),\n", + " (805724, 2434),\n", + " (790535, 2562),\n", + " (796383, 2383),\n", + " (107452, 354),\n", + " (203694, 635)]" + ] + }, + "execution_count": 48, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "%%sql\n" + "%%sql\n", + "SELECT SUM(amount), SUM(quantity)\n", + "FROM receipt\n", + "GROUP BY store_cd;" ] }, { @@ -491,11 +3880,84 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 50, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* postgresql://padawan:***@db:5432/dsdojo_db\n", + "10 rows affected.\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
max
20180211
20181228
20180106
20190503
20180621
20190511
20190708
20170517
20190720
20170729
" + ], + "text/plain": [ + "[(20180211,),\n", + " (20181228,),\n", + " (20180106,),\n", + " (20190503,),\n", + " (20180621,),\n", + " (20190511,),\n", + " (20190708,),\n", + " (20170517,),\n", + " (20190720,),\n", + " (20170729,)]" + ] + }, + "execution_count": 50, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "%%sql\n" + "%%sql\n", + "SELECT MAX(sales_ymd)\n", + "FROM receipt\n", + "GROUP BY customer_id\n", + "LIMIT 10;" ] }, { @@ -508,11 +3970,84 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 51, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* postgresql://padawan:***@db:5432/dsdojo_db\n", + "10 rows affected.\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
min
20180211
20181228
20180106
20190503
20170318
20170201
20170527
20170517
20170718
20170729
" + ], + "text/plain": [ + "[(20180211,),\n", + " (20181228,),\n", + " (20180106,),\n", + " (20190503,),\n", + " (20170318,),\n", + " (20170201,),\n", + " (20170527,),\n", + " (20170517,),\n", + " (20170718,),\n", + " (20170729,)]" + ] + }, + "execution_count": 51, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "%%sql\n" + "%%sql\n", + "SELECT MIN(sales_ymd)\n", + "FROM receipt\n", + "GROUP BY customer_id\n", + "LIMIT 10;" ] }, { @@ -525,11 +4060,111 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 58, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* postgresql://padawan:***@db:5432/dsdojo_db\n", + "10 rows affected.\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
customer_idmax_sales_ymdmin_sales_ymd
CS0292120000332018062120170318
CS0075150001192019051120170201
CS0345150001232019070820170527
CS0264140000142019072020170718
CS0105150000822018120420180518
CS0193150000452017092020170423
CS0085130000992019030820170722
CS0076150000702019102520170929
CS0254150001552019102620170314
CS0164140000632019061720170109
" + ], + "text/plain": [ + "[('CS029212000033', 20180621, 20170318),\n", + " ('CS007515000119', 20190511, 20170201),\n", + " ('CS034515000123', 20190708, 20170527),\n", + " ('CS026414000014', 20190720, 20170718),\n", + " ('CS010515000082', 20181204, 20180518),\n", + " ('CS019315000045', 20170920, 20170423),\n", + " ('CS008513000099', 20190308, 20170722),\n", + " ('CS007615000070', 20191025, 20170929),\n", + " ('CS025415000155', 20191026, 20170314),\n", + " ('CS016414000063', 20190617, 20170109)]" + ] + }, + "execution_count": 58, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "%%sql\n" + "%%sql\n", + "WITH max_min AS (\n", + " SELECT customer_id, MAX(sales_ymd) AS max_sales_ymd, MIN(sales_ymd) AS min_sales_ymd\n", + " FROM receipt\n", + " GROUP BY customer_id\n", + ")\n", + "SELECT max_min.*\n", + "FROM max_min\n", + "WHERE max_sales_ymd != min_sales_ymd\n", + "LIMIT 10;" ] }, { @@ -542,11 +4177,71 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 59, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* postgresql://padawan:***@db:5432/dsdojo_db\n", + "5 rows affected.\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
store_cdamount_avg
S13052402.8674698795180723
S13015351.1119604316546763
S13003350.9155188246097337
S14010348.7912621359223301
S13001348.4703862660944206
" + ], + "text/plain": [ + "[('S13052', Decimal('402.8674698795180723')),\n", + " ('S13015', Decimal('351.1119604316546763')),\n", + " ('S13003', Decimal('350.9155188246097337')),\n", + " ('S14010', Decimal('348.7912621359223301')),\n", + " ('S13001', Decimal('348.4703862660944206'))]" + ] + }, + "execution_count": 59, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "%%sql\n" + "%%sql\n", + "SELECT store_cd, avg(amount) AS amount_avg\n", + "FROM receipt\n", + "GROUP BY store_cd\n", + "ORDER BY amount_avg DESC\n", + "LIMIT 5;" ] }, { @@ -559,11 +4254,71 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 64, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* postgresql://padawan:***@db:5432/dsdojo_db\n", + "5 rows affected.\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
store_cdmedian
S13052190.0
S14010188.0
S14050185.0
S13003180.0
S13018180.0
" + ], + "text/plain": [ + "[('S13052', 190.0),\n", + " ('S14010', 188.0),\n", + " ('S14050', 185.0),\n", + " ('S13003', 180.0),\n", + " ('S13018', 180.0)]" + ] + }, + "execution_count": 64, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "%%sql\n" + "%%sql\n", + "SELECT store_cd, PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY amount) AS median\n", + "FROM receipt\n", + "GROUP BY store_cd\n", + "ORDER BY median DESC\n", + "LIMIT 5;" ] }, { @@ -576,11 +4331,95 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 70, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* postgresql://padawan:***@db:5432/dsdojo_db\n", + "10 rows affected.\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
store_cdfreq
S130181257
S140261248
S140121237
S130321234
S130081230
S120291226
S130171220
S130161215
S140281214
S130091206
" + ], + "text/plain": [ + "[('S13018', 1257),\n", + " ('S14026', 1248),\n", + " ('S14012', 1237),\n", + " ('S13032', 1234),\n", + " ('S13008', 1230),\n", + " ('S12029', 1226),\n", + " ('S13017', 1220),\n", + " ('S13016', 1215),\n", + " ('S14028', 1214),\n", + " ('S13009', 1206)]" + ] + }, + "execution_count": 70, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "%%sql\n" + "%%sql\n", + "SELECT store_cd, count(distinct product_cd) AS freq\n", + "FROM receipt\n", + "GROUP BY store_cd\n", + "LIMIT 10;" ] }, { @@ -593,11 +4432,71 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 73, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* postgresql://padawan:***@db:5432/dsdojo_db\n", + "5 rows affected.\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
store_cdvariance
S13052441863.252526233968
S14011306442.242431568709
S14034297068.392740060738
S13001295558.842617712478
S13015295427.197085853584
" + ], + "text/plain": [ + "[('S13052', Decimal('441863.252526233968')),\n", + " ('S14011', Decimal('306442.242431568709')),\n", + " ('S14034', Decimal('297068.392740060738')),\n", + " ('S13001', Decimal('295558.842617712478')),\n", + " ('S13015', Decimal('295427.197085853584'))]" + ] + }, + "execution_count": 73, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "%%sql\n" + "%%sql\n", + "SELECT store_cd, VARIANCE(amount) as variance\n", + "FROM receipt\n", + "GROUP BY store_cd\n", + "ORDER BY variance DESC\n", + "LIMIT 5;" ] }, { @@ -610,11 +4509,71 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 75, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* postgresql://padawan:***@db:5432/dsdojo_db\n", + "5 rows affected.\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
store_cdvariance
S13052664.727953772244
S14011553.572255836190
S14034545.039808399406
S13001543.653237475610
S13015543.532149082144
" + ], + "text/plain": [ + "[('S13052', Decimal('664.727953772244')),\n", + " ('S14011', Decimal('553.572255836190')),\n", + " ('S14034', Decimal('545.039808399406')),\n", + " ('S13001', Decimal('543.653237475610')),\n", + " ('S13015', Decimal('543.532149082144'))]" + ] + }, + "execution_count": 75, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "%%sql\n" + "%%sql\n", + "SELECT store_cd, STDDEV(amount) as variance\n", + "FROM receipt\n", + "GROUP BY store_cd\n", + "ORDER BY variance DESC\n", + "LIMIT 5;" ] }, { @@ -627,11 +4586,46 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 79, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* postgresql://padawan:***@db:5432/dsdojo_db\n", + "1 rows affected.\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
percentile_disc
102
" + ], + "text/plain": [ + "[(102,)]" + ] + }, + "execution_count": 79, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "%%sql\n" + "%%sql\n", + "SELECT PERCENTILE_DISC(0.25) WITHIN GROUP (ORDER BY amount)\n", + "FROM receipt" ] }, { @@ -1893,7 +5887,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.8" + "version": "3.11.9" } }, "nbformat": 4, From a70e889c2ffce6ee2c976a75f72691accba5d20f Mon Sep 17 00:00:00 2001 From: Wataru Sugiura <38929316+flat35hd99@users.noreply.github.com> Date: Sun, 11 Aug 2024 11:41:21 +0000 Subject: [PATCH 2/4] Add publishing docker image --- .github/workflows/publish_image.yml | 60 +++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/publish_image.yml diff --git a/.github/workflows/publish_image.yml b/.github/workflows/publish_image.yml new file mode 100644 index 00000000..1d7790cb --- /dev/null +++ b/.github/workflows/publish_image.yml @@ -0,0 +1,60 @@ +# +name: Create and publish a Docker image + +# Configures this workflow to run every time a change is pushed to the branch called `release`. +on: + push: + branches: ['main'] + +# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds. +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu. +jobs: + build-and-push-image: + runs-on: ubuntu-latest + # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. + permissions: + contents: read + packages: write + attestations: write + id-token: write + # + steps: + - name: Checkout repository + uses: actions/checkout@v4 + # Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here. + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + # This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels. + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages. + # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository. + # It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step. + - name: Build and push Docker image + id: push + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + # This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see "[AUTOTITLE](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds)." + - name: Generate artifact attestation + uses: actions/attest-build-provenance@v1 + with: + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} + subject-digest: ${{ steps.push.outputs.digest }} + push-to-registry: true + From 20f1410aa827b192515d667d966611687af52d9f Mon Sep 17 00:00:00 2001 From: Wataru Sugiura <38929316+flat35hd99@users.noreply.github.com> Date: Sun, 11 Aug 2024 11:42:24 +0000 Subject: [PATCH 3/4] Hotfix --- .github/workflows/publish_image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_image.yml b/.github/workflows/publish_image.yml index 1d7790cb..7dcd4b37 100644 --- a/.github/workflows/publish_image.yml +++ b/.github/workflows/publish_image.yml @@ -4,7 +4,7 @@ name: Create and publish a Docker image # Configures this workflow to run every time a change is pushed to the branch called `release`. on: push: - branches: ['main'] + branches: ['master'] # Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds. env: From 089578dbd107a36f9a380790779c8c7a6d54607e Mon Sep 17 00:00:00 2001 From: Wataru Sugiura <38929316+flat35hd99@users.noreply.github.com> Date: Sun, 11 Aug 2024 12:36:00 +0000 Subject: [PATCH 4/4] =?UTF-8?q?38=E3=81=BE=E3=81=A7=E3=82=84=E3=81=A3?= =?UTF-8?q?=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker/doc/preprocess_knock_SQL.html | 605 +++++++++++++++++++++- docker/work/preprocess_knock_SQL.ipynb | 677 ++++++++++++++++++++++++- 2 files changed, 1248 insertions(+), 34 deletions(-) diff --git a/docker/doc/preprocess_knock_SQL.html b/docker/doc/preprocess_knock_SQL.html index c0dd4112..fae70a8e 100644 --- a/docker/doc/preprocess_knock_SQL.html +++ b/docker/doc/preprocess_knock_SQL.html @@ -7559,7 +7559,7 @@

はじめに