{ "cells": [ { "cell_type": "code", "execution_count": 9, "metadata": { "pycharm": { "name": "#%%\n" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CPU times: total: 5.89 s\n", "Wall time: 6.14 s\n" ] }, { "data": { "text/plain": "(31371, 9)" }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%%time\n", "import pandas as pd\n", "df = pd.read_excel(\"G:\\Mon Drive\\Ziwig-Health\\Data\\Extract_Prof_Patient_List_new.xlsx\", header=2)\n", "df.shape" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "pycharm": { "name": "#%%\n" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CPU times: total: 46.9 ms\n", "Wall time: 49.9 ms\n" ] }, { "data": { "text/plain": "isStartMedicalRecord False True \nisFinishMedicalRecord False False True\ncreatedAt \n2020-11-30 169 9 78\n2020-12-31 226 16 147\n2021-01-31 149 388 842\n2021-02-28 238 164 606\n2021-03-31 652 453 2262\n2021-04-30 250 118 1141\n2021-05-31 269 144 1106\n2021-06-30 283 150 1012\n2021-07-31 227 127 883\n2021-08-31 196 111 912\n2021-09-30 223 142 1254\n2021-10-31 224 112 1176\n2021-11-30 229 110 988\n2021-12-31 466 111 925\n2022-01-31 753 287 1766\n2022-02-28 1095 549 2362\n2022-03-31 520 176 1242\n2022-04-30 395 125 849\n2022-05-31 363 99 771\n2022-06-30 233 65 433", "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
isStartMedicalRecordFalseTrue
isFinishMedicalRecordFalseFalseTrue
createdAt
2020-11-30169978
2020-12-3122616147
2021-01-31149388842
2021-02-28238164606
2021-03-316524532262
2021-04-302501181141
2021-05-312691441106
2021-06-302831501012
2021-07-31227127883
2021-08-31196111912
2021-09-302231421254
2021-10-312241121176
2021-11-30229110988
2021-12-31466111925
2022-01-317532871766
2022-02-2810955492362
2022-03-315201761242
2022-04-30395125849
2022-05-3136399771
2022-06-3023365433
\n
" }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%%time\n", "pd.pivot_table(data = df, index=pd.Grouper(key=\"createdAt\", freq=\"M\"), columns=[\"isStartMedicalRecord\",\"isFinishMedicalRecord\"], values=\"fullName\", aggfunc=\"count\", fill_value= 0)" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false }, "pycharm": { "name": "#%%\n" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CPU times: total: 46.9 ms\n", "Wall time: 46.9 ms\n" ] }, { "data": { "text/plain": "isStartMedicalRecord False True\ncreatedAt \n2020-11-30 169 87\n2020-12-31 226 163\n2021-01-31 149 1230\n2021-02-28 238 770\n2021-03-31 652 2715\n2021-04-30 250 1259\n2021-05-31 269 1250\n2021-06-30 283 1162\n2021-07-31 227 1010\n2021-08-31 196 1023\n2021-09-30 223 1396\n2021-10-31 224 1288\n2021-11-30 229 1098\n2021-12-31 466 1036\n2022-01-31 753 2053\n2022-02-28 1095 2911\n2022-03-31 520 1418\n2022-04-30 395 974\n2022-05-31 363 870\n2022-06-30 233 498", "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
isStartMedicalRecordFalseTrue
createdAt
2020-11-3016987
2020-12-31226163
2021-01-311491230
2021-02-28238770
2021-03-316522715
2021-04-302501259
2021-05-312691250
2021-06-302831162
2021-07-312271010
2021-08-311961023
2021-09-302231396
2021-10-312241288
2021-11-302291098
2021-12-314661036
2022-01-317532053
2022-02-2810952911
2022-03-315201418
2022-04-30395974
2022-05-31363870
2022-06-30233498
\n
" }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%%time\n", "pd.pivot_table(data = df, index=pd.Grouper(key=\"createdAt\", freq=\"M\"), columns=[\"isStartMedicalRecord\"], values=\"fullName\", aggfunc=\"count\", fill_value=0)" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false }, "pycharm": { "name": "#%%\n" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CPU times: total: 62.5 ms\n", "Wall time: 58.8 ms\n" ] }, { "data": { "text/plain": "isFinishMedicalRecord False True\ncreatedAt \n2020-11-30 178 78\n2020-12-31 242 147\n2021-01-31 537 842\n2021-02-28 402 606\n2021-03-31 1105 2262\n2021-04-30 368 1141\n2021-05-31 413 1106\n2021-06-30 433 1012\n2021-07-31 354 883\n2021-08-31 307 912\n2021-09-30 365 1254\n2021-10-31 336 1176\n2021-11-30 339 988\n2021-12-31 577 925\n2022-01-31 1040 1766\n2022-02-28 1644 2362\n2022-03-31 696 1242\n2022-04-30 520 849\n2022-05-31 462 771\n2022-06-30 298 433", "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
isFinishMedicalRecordFalseTrue
createdAt
2020-11-3017878
2020-12-31242147
2021-01-31537842
2021-02-28402606
2021-03-3111052262
2021-04-303681141
2021-05-314131106
2021-06-304331012
2021-07-31354883
2021-08-31307912
2021-09-303651254
2021-10-313361176
2021-11-30339988
2021-12-31577925
2022-01-3110401766
2022-02-2816442362
2022-03-316961242
2022-04-30520849
2022-05-31462771
2022-06-30298433
\n
" }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%%time\n", "pd.pivot_table(data = df, index=pd.Grouper(key=\"createdAt\", freq=\"M\"), columns=[\"isFinishMedicalRecord\"], values=\"fullName\", aggfunc=\"count\", fill_value=0)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.12" } }, "nbformat": 4, "nbformat_minor": 4 }