{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "b9144326",
   "metadata": {},
   "source": [
    "### Calculate replacement values for live deployment"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2a7b60d6",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "from pathlib import Path\n",
    "import yaml"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "197cb8a6",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TODO: insert path to database\n",
    "dataset_path = Path(r\"\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6cf26eb2",
   "metadata": {},
   "outputs": [],
   "source": [
    "df=pd.read_parquet(dataset_path)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f2c5679e",
   "metadata": {},
   "outputs": [],
   "source": [
    "pd.set_option(\"display.max_rows\", None)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e88981b2",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "# optional: your dataframe filtering code ...\n",
    "\n",
    "medians = df.median()\n",
    "median_dict = medians.to_dict()\n",
    "\n",
    "# Wrap in fallback key\n",
    "output = {'fallback': median_dict}\n",
    "\n",
    "# Save to YAML\n",
    "with open('config.yaml', 'w') as f:\n",
    "    yaml.dump(output, f, default_flow_style=False, sort_keys=False)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "310",
   "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.10.19"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
