{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "provenance": [] }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" } }, "cells": [ { "cell_type": "code", "source": [ "! pip install faker" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "b4GuAy2rBGxs", "outputId": "f78fa63f-63f8-4350-f216-3f671622e0cf" }, "execution_count": 2, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Collecting faker\n", " Downloading Faker-24.4.0-py3-none-any.whl (1.8 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.8/1.8 MB\u001b[0m \u001b[31m10.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hRequirement already satisfied: python-dateutil>=2.4 in /usr/local/lib/python3.10/dist-packages (from faker) (2.8.2)\n", "Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-packages (from python-dateutil>=2.4->faker) (1.16.0)\n", "Installing collected packages: faker\n", "Successfully installed faker-24.4.0\n" ] } ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "id": "o8w2xsKkA72N" }, "outputs": [], "source": [ "import pandas as pd\n", "import random\n", "from faker import Faker\n", "from datetime import datetime, timedelta\n", "from tqdm import tqdm" ] }, { "cell_type": "code", "source": [ "# Initialize Faker\n", "fake = Faker()\n", "\n", "# Generate data\n", "data = []\n", "\n", "for _ in tqdm(range(100)): # Changed from 20 to 100 to generate 100 rows\n", " first_name = fake.first_name()\n", " last_name = fake.last_name()\n", " policy_no = fake.unique.random_number(digits=8, fix_len=True)\n", " gender = random.choice(['Male', 'Female', 'Other'])\n", " address = fake.address()\n", " state = fake.state()\n", " physician_office_address = fake.address()\n", " time_of_test = fake.date_time_this_decade().strftime('%Y-%m-%d %H:%M:%S') # Formatted time\n", "\n", " # Random medical test results\n", " a1c = round(random.uniform(4.0, 14.0), 1) # A1C levels\n", " glucose = round(random.uniform(70, 150), 1) # Glucose levels\n", " calcium = round(random.uniform(8.5, 10.2), 1) # Calcium levels\n", " electrolytes = \"Normal\" if random.choice([True, False]) else \"Abnormal\" # Electrolytes status\n", " cholesterol = round(random.uniform(125, 240), 1) # Cholesterol levels\n", " esr = random.randint(0, 100) # ESR levels\n", "\n", " # Aggregating BMP results\n", " bmp_glucose = f\"Glucose: {glucose}\"\n", " bmp_calcium = f\"Calcium: {calcium}\"\n", " bmp_electrolytes = f\"Electrolytes: {electrolytes}\"\n", "\n", " data.append([first_name, last_name, policy_no, gender, address, state, physician_office_address, time_of_test, a1c, bmp_glucose, bmp_calcium, bmp_electrolytes, cholesterol, esr])" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "q0JyotoZBCw8", "outputId": "bdf3f2d3-1e10-41cc-862c-5a8fcc981a6c" }, "execution_count": 5, "outputs": [ { "output_type": "stream", "name": "stderr", "text": [ "100%|██████████| 100/100 [00:00<00:00, 541.24it/s]\n" ] } ] }, { "cell_type": "code", "source": [ "# Creating DataFrame\n", "df = pd.DataFrame(data, columns=[\"First Name\", \"Last Name\", \"Policy No.\", \"Gender\", \"Address\", \"State\", \"Physician Office Address\", \"Time of Test\", \"A1C (diabetes)\", \"BMP (glucose)\", \"BMP (calcium)\", \"BMP (electrolytes)\", \"Lipid Panel (cholesterol)\", \"ESR (blood cell clumps)\"])" ], "metadata": { "id": "dRIS5WXJBF7M" }, "execution_count": 6, "outputs": [] }, { "cell_type": "code", "source": [ "df" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 615 }, "id": "-YUuq4OrBO8s", "outputId": "4b2c4bc6-9aca-487b-e6f5-e33d684bf627" }, "execution_count": 8, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ " First Name Last Name Policy No. Gender \\\n", "0 John Williams 51405852 Male \n", "1 Matthew Barrett 86698828 Female \n", "2 Michael Williams 97705492 Other \n", "3 Billy Jones 42019134 Other \n", "4 Jessica Lawson 62074003 Female \n", ".. ... ... ... ... \n", "95 Peter Burns 58173378 Other \n", "96 Nicole Campbell 96638320 Female \n", "97 Jeffrey Moore 25800342 Male \n", "98 Albert Collins 38748339 Other \n", "99 Anthony Arias 29343897 Male \n", "\n", " Address State \\\n", "0 06021 Andrews Plains\\nNorth Barbaraview, WA 84509 Texas \n", "1 02997 Deborah Path Suite 795\\nDeborahmouth, NJ... Delaware \n", "2 4519 Joseph Extensions Apt. 395\\nPort William,... Kentucky \n", "3 113 Rivera Plain Apt. 143\\nPort Cindy, CO 74694 South Carolina \n", "4 82657 Ruiz Point\\nLake Christophershire, KS 37543 Delaware \n", ".. ... ... \n", "95 USCGC Parker\\nFPO AA 16320 New York \n", "96 USS Davis\\nFPO AP 68621 Vermont \n", "97 9240 Anthony Flat Apt. 187\\nLake Stephenberg, ... Georgia \n", "98 5230 Gary Motorway\\nWufort, VT 79419 Delaware \n", "99 814 Christopher Meadows\\nPatriciashire, NY 73616 Arkansas \n", "\n", " Physician Office Address Time of Test \\\n", "0 Unit 9742 Box 1185\\nDPO AP 13090 2021-11-25 08:48:21 \n", "1 711 Scott Gateway Suite 873\\nWendyburgh, ME 72114 2020-05-16 18:28:15 \n", "2 732 Bryant Street Suite 463\\nNew Jessicaview, ... 2022-04-14 22:44:55 \n", "3 24170 Merritt Mountain Apt. 882\\nSnydershire, ... 2023-10-09 12:48:11 \n", "4 840 Rachel Freeway\\nPort Robert, NC 93052 2021-01-24 18:34:26 \n", ".. ... ... \n", "95 30807 Mitchell Estates\\nGregorybury, KY 95175 2020-01-16 08:08:59 \n", "96 3771 Maria Bypass Apt. 651\\nLake Lindsey, MD 0... 2023-10-17 19:27:21 \n", "97 2683 Thomas Court Apt. 694\\nRachaelchester, CT... 2020-10-26 14:30:56 \n", "98 79209 Garner Trafficway\\nPort William, KY 91119 2020-03-25 15:18:29 \n", "99 035 Sharon Road Suite 873\\nNorth Jamesmouth, A... 2021-01-07 17:20:17 \n", "\n", " A1C (diabetes) BMP (glucose) BMP (calcium) BMP (electrolytes) \\\n", "0 8.3 Glucose: 105.1 Calcium: 9.4 Electrolytes: Normal \n", "1 4.9 Glucose: 140.1 Calcium: 9.9 Electrolytes: Abnormal \n", "2 8.8 Glucose: 103.6 Calcium: 9.3 Electrolytes: Abnormal \n", "3 6.7 Glucose: 124.4 Calcium: 9.4 Electrolytes: Normal \n", "4 12.1 Glucose: 135.4 Calcium: 8.6 Electrolytes: Abnormal \n", ".. ... ... ... ... \n", "95 8.7 Glucose: 143.4 Calcium: 9.0 Electrolytes: Abnormal \n", "96 5.7 Glucose: 126.7 Calcium: 10.0 Electrolytes: Abnormal \n", "97 9.0 Glucose: 133.6 Calcium: 8.7 Electrolytes: Normal \n", "98 9.2 Glucose: 78.1 Calcium: 9.8 Electrolytes: Abnormal \n", "99 13.7 Glucose: 113.7 Calcium: 8.7 Electrolytes: Normal \n", "\n", " Lipid Panel (cholesterol) ESR (blood cell clumps) \n", "0 217.2 23 \n", "1 165.0 36 \n", "2 183.9 34 \n", "3 176.4 13 \n", "4 129.9 29 \n", ".. ... ... \n", "95 151.7 7 \n", "96 157.2 19 \n", "97 141.0 89 \n", "98 228.4 84 \n", "99 214.2 50 \n", "\n", "[100 rows x 14 columns]" ], "text/html": [ "\n", "
\n", " | First Name | \n", "Last Name | \n", "Policy No. | \n", "Gender | \n", "Address | \n", "State | \n", "Physician Office Address | \n", "Time of Test | \n", "A1C (diabetes) | \n", "BMP (glucose) | \n", "BMP (calcium) | \n", "BMP (electrolytes) | \n", "Lipid Panel (cholesterol) | \n", "ESR (blood cell clumps) | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "John | \n", "Williams | \n", "51405852 | \n", "Male | \n", "06021 Andrews Plains\\nNorth Barbaraview, WA 84509 | \n", "Texas | \n", "Unit 9742 Box 1185\\nDPO AP 13090 | \n", "2021-11-25 08:48:21 | \n", "8.3 | \n", "Glucose: 105.1 | \n", "Calcium: 9.4 | \n", "Electrolytes: Normal | \n", "217.2 | \n", "23 | \n", "
1 | \n", "Matthew | \n", "Barrett | \n", "86698828 | \n", "Female | \n", "02997 Deborah Path Suite 795\\nDeborahmouth, NJ... | \n", "Delaware | \n", "711 Scott Gateway Suite 873\\nWendyburgh, ME 72114 | \n", "2020-05-16 18:28:15 | \n", "4.9 | \n", "Glucose: 140.1 | \n", "Calcium: 9.9 | \n", "Electrolytes: Abnormal | \n", "165.0 | \n", "36 | \n", "
2 | \n", "Michael | \n", "Williams | \n", "97705492 | \n", "Other | \n", "4519 Joseph Extensions Apt. 395\\nPort William,... | \n", "Kentucky | \n", "732 Bryant Street Suite 463\\nNew Jessicaview, ... | \n", "2022-04-14 22:44:55 | \n", "8.8 | \n", "Glucose: 103.6 | \n", "Calcium: 9.3 | \n", "Electrolytes: Abnormal | \n", "183.9 | \n", "34 | \n", "
3 | \n", "Billy | \n", "Jones | \n", "42019134 | \n", "Other | \n", "113 Rivera Plain Apt. 143\\nPort Cindy, CO 74694 | \n", "South Carolina | \n", "24170 Merritt Mountain Apt. 882\\nSnydershire, ... | \n", "2023-10-09 12:48:11 | \n", "6.7 | \n", "Glucose: 124.4 | \n", "Calcium: 9.4 | \n", "Electrolytes: Normal | \n", "176.4 | \n", "13 | \n", "
4 | \n", "Jessica | \n", "Lawson | \n", "62074003 | \n", "Female | \n", "82657 Ruiz Point\\nLake Christophershire, KS 37543 | \n", "Delaware | \n", "840 Rachel Freeway\\nPort Robert, NC 93052 | \n", "2021-01-24 18:34:26 | \n", "12.1 | \n", "Glucose: 135.4 | \n", "Calcium: 8.6 | \n", "Electrolytes: Abnormal | \n", "129.9 | \n", "29 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
95 | \n", "Peter | \n", "Burns | \n", "58173378 | \n", "Other | \n", "USCGC Parker\\nFPO AA 16320 | \n", "New York | \n", "30807 Mitchell Estates\\nGregorybury, KY 95175 | \n", "2020-01-16 08:08:59 | \n", "8.7 | \n", "Glucose: 143.4 | \n", "Calcium: 9.0 | \n", "Electrolytes: Abnormal | \n", "151.7 | \n", "7 | \n", "
96 | \n", "Nicole | \n", "Campbell | \n", "96638320 | \n", "Female | \n", "USS Davis\\nFPO AP 68621 | \n", "Vermont | \n", "3771 Maria Bypass Apt. 651\\nLake Lindsey, MD 0... | \n", "2023-10-17 19:27:21 | \n", "5.7 | \n", "Glucose: 126.7 | \n", "Calcium: 10.0 | \n", "Electrolytes: Abnormal | \n", "157.2 | \n", "19 | \n", "
97 | \n", "Jeffrey | \n", "Moore | \n", "25800342 | \n", "Male | \n", "9240 Anthony Flat Apt. 187\\nLake Stephenberg, ... | \n", "Georgia | \n", "2683 Thomas Court Apt. 694\\nRachaelchester, CT... | \n", "2020-10-26 14:30:56 | \n", "9.0 | \n", "Glucose: 133.6 | \n", "Calcium: 8.7 | \n", "Electrolytes: Normal | \n", "141.0 | \n", "89 | \n", "
98 | \n", "Albert | \n", "Collins | \n", "38748339 | \n", "Other | \n", "5230 Gary Motorway\\nWufort, VT 79419 | \n", "Delaware | \n", "79209 Garner Trafficway\\nPort William, KY 91119 | \n", "2020-03-25 15:18:29 | \n", "9.2 | \n", "Glucose: 78.1 | \n", "Calcium: 9.8 | \n", "Electrolytes: Abnormal | \n", "228.4 | \n", "84 | \n", "
99 | \n", "Anthony | \n", "Arias | \n", "29343897 | \n", "Male | \n", "814 Christopher Meadows\\nPatriciashire, NY 73616 | \n", "Arkansas | \n", "035 Sharon Road Suite 873\\nNorth Jamesmouth, A... | \n", "2021-01-07 17:20:17 | \n", "13.7 | \n", "Glucose: 113.7 | \n", "Calcium: 8.7 | \n", "Electrolytes: Normal | \n", "214.2 | \n", "50 | \n", "
100 rows × 14 columns
\n", "