{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "6b2c6dad-a9b0-4463-a129-7b991d51487d",
   "metadata": {},
   "outputs": [],
   "source": [
    "%load_ext autoreload\n",
    "%autoreload 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "165ff3f2-fd3c-48ce-ad93-af237909d8d3",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "from pathlib import Path\n",
    "\n",
    "from sentence_transformers import SentenceTransformer\n",
    "\n",
    "from lang_main import (\n",
    "    save_pickle,\n",
    "    load_pickle,\n",
    "    SAVE_PATH_FOLDER,\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "1013213d-d651-4ec7-a8ac-321c83b2a344",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "A:\\Arbeitsaufgaben\\lang-main\\.venv\\Lib\\site-packages\\huggingface_hub\\file_download.py:1132: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.\n",
      "  warnings.warn(\n"
     ]
    }
   ],
   "source": [
    "model_stfr = SentenceTransformer('sentence-transformers/all-mpnet-base-v2')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "d2c78879-ba2c-4b36-9fa2-6a9a138f04fc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "WindowsPath('A:/Arbeitsaufgaben/lang-main/test-notebooks/results/test_new2')"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p = Path(os.getcwd()) / SAVE_PATH_FOLDER\n",
    "p"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "b9e65423-bc49-49d5-8bd0-875fcb014f7e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[WindowsPath('A:/Arbeitsaufgaben/lang-main/test-notebooks/results/test_new2/Pipe-TargetFeature_Step-3_remove_NA.pickle'),\n",
       " WindowsPath('A:/Arbeitsaufgaben/lang-main/test-notebooks/results/test_new2/map_candidates.pkl'),\n",
       " WindowsPath('A:/Arbeitsaufgaben/lang-main/test-notebooks/results/test_new2/map_texts.pkl'),\n",
       " WindowsPath('A:/Arbeitsaufgaben/lang-main/test-notebooks/results/test_new2/data.pkl')]"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "folder = list(p.glob(r'*'))\n",
    "folder"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c0679937-d669-4eaa-aec6-85d12edc4a0a",
   "metadata": {},
   "source": [
    "---\n",
    "\n",
    "# Gather timeline candidates"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "e4abc1cc-e69d-43a3-b328-2ef3f08a9c90",
   "metadata": {},
   "outputs": [],
   "source": [
    "from lang_main.analysis.timeline import (\n",
    "    remove_non_relevant_obj_ids,\n",
    "    filter_activities_per_obj_id,\n",
    "    generate_model_input,\n",
    "    get_timeline_candidates_index,\n",
    "    transform_timeline_candidates,\n",
    "    map_obj_texts,\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "369838fc-3e77-4a9a-ac1f-e71a380e0353",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "shared:INFO | 2024-05-22 13:45:11 +0000 | Loaded file successfully.\n",
      "len(data)=123457\n",
      "timeline:INFO | 2024-05-22 13:45:11 +0000 | Removing non-relevant ObjectIDs from dataset\n",
      "timeline:DEBUG | 2024-05-22 13:45:12 +0000 | Ignored ObjectIDs: (0,)\n",
      "timeline:INFO | 2024-05-22 13:45:12 +0000 | Non-relevant ObjectIDs removed successfully\n",
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Index: 122958 entries, 0 to 123456\n",
      "Data columns (total 20 columns):\n",
      " #   Column                   Non-Null Count   Dtype         \n",
      "---  ------                   --------------   -----         \n",
      " 0   VorgangsID               122958 non-null  int64         \n",
      " 1   ObjektID                 122958 non-null  int64         \n",
      " 2   HObjektText              122953 non-null  object        \n",
      " 3   ObjektArtID              122958 non-null  int64         \n",
      " 4   ObjektArtText            122880 non-null  object        \n",
      " 5   VorgangsTypID            122958 non-null  int64         \n",
      " 6   VorgangsTypName          122958 non-null  object        \n",
      " 7   VorgangsDatum            122958 non-null  datetime64[ns]\n",
      " 8   VorgangsStatusId         122958 non-null  int64         \n",
      " 9   VorgangsPrioritaet       122958 non-null  int64         \n",
      " 10  VorgangsBeschreibung     122958 non-null  object        \n",
      " 11  VorgangsOrt              0 non-null       object        \n",
      " 12  VorgangsArtText          122958 non-null  object        \n",
      " 13  ErledigungsDatum         122958 non-null  datetime64[ns]\n",
      " 14  ErledigungsArtText       122465 non-null  object        \n",
      " 15  ErledigungsBeschreibung  115562 non-null  object        \n",
      " 16  MPMelderArbeitsplatz     5709 non-null    object        \n",
      " 17  MPAbteilungBezeichnung   5709 non-null    object        \n",
      " 18  Arbeitsbeginn            119459 non-null  datetime64[ns]\n",
      " 19  ErstellungsDatum         122958 non-null  datetime64[ns]\n",
      "dtypes: datetime64[ns](4), int64(6), object(10)\n",
      "memory usage: 19.7+ MB\n"
     ]
    }
   ],
   "source": [
    "ret = load_pickle(folder[0])\n",
    "data = ret[0]\n",
    "print(f\"{len(data)=}\")\n",
    "data = remove_non_relevant_obj_ids(data, thresh_unique_feat_per_id=3)\n",
    "data.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0afe2888-ff74-4be8-b7e6-374546942070",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3d22728c-2fd9-4742-a4be-61909f14cfd7",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "79973397-4df2-43ca-9f40-182644592337",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['Reparaturauftrag (Portal)', 'Wartung', 'Störungsmeldung'],\n",
       "      dtype=object)"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['VorgangsTypName'].unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "b10fbf48-9e1a-4d2b-9b41-b6711b366a34",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "timeline:INFO | 2024-05-22 13:45:12 +0000 | Filtering activities per ObjectID\n",
      "timeline:INFO | 2024-05-22 13:45:12 +0000 | Activities per ObjectID filtered successfully\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "ObjektID\n",
       "1       283\n",
       "1654    243\n",
       "7       223\n",
       "151     189\n",
       "140     140\n",
       "       ... \n",
       "1698      2\n",
       "683       2\n",
       "1135      2\n",
       "2170      2\n",
       "297       2\n",
       "Name: count, Length: 366, dtype: int64"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "activity_types = [\n",
    "    'Reparaturauftrag (Portal)',\n",
    "    'Störungsmeldung',\n",
    "]\n",
    "\n",
    "(data, num_activities_per_obj_id) =\\\n",
    "filter_activities_per_obj_id(data, relevant_activity_types=activity_types)\n",
    "num_activities_per_obj_id"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "39207835-e7b2-43c8-b6a6-8d685ac488a6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Index: 6104 entries, 0 to 123456\n",
      "Data columns (total 20 columns):\n",
      " #   Column                   Non-Null Count  Dtype         \n",
      "---  ------                   --------------  -----         \n",
      " 0   VorgangsID               6104 non-null   int64         \n",
      " 1   ObjektID                 6104 non-null   int64         \n",
      " 2   HObjektText              6103 non-null   object        \n",
      " 3   ObjektArtID              6104 non-null   int64         \n",
      " 4   ObjektArtText            6087 non-null   object        \n",
      " 5   VorgangsTypID            6104 non-null   int64         \n",
      " 6   VorgangsTypName          6104 non-null   object        \n",
      " 7   VorgangsDatum            6104 non-null   datetime64[ns]\n",
      " 8   VorgangsStatusId         6104 non-null   int64         \n",
      " 9   VorgangsPrioritaet       6104 non-null   int64         \n",
      " 10  VorgangsBeschreibung     6104 non-null   object        \n",
      " 11  VorgangsOrt              0 non-null      object        \n",
      " 12  VorgangsArtText          6104 non-null   object        \n",
      " 13  ErledigungsDatum         6104 non-null   datetime64[ns]\n",
      " 14  ErledigungsArtText       6079 non-null   object        \n",
      " 15  ErledigungsBeschreibung  5812 non-null   object        \n",
      " 16  MPMelderArbeitsplatz     5672 non-null   object        \n",
      " 17  MPAbteilungBezeichnung   5672 non-null   object        \n",
      " 18  Arbeitsbeginn            5915 non-null   datetime64[ns]\n",
      " 19  ErstellungsDatum         6104 non-null   datetime64[ns]\n",
      "dtypes: datetime64[ns](4), int64(6), object(10)\n",
      "memory usage: 1001.4+ KB\n"
     ]
    }
   ],
   "source": [
    "data.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "b848d8ee-cdf3-4b92-ac5b-e5a74e562e92",
   "metadata": {},
   "outputs": [],
   "source": [
    "# VorgangsTypName, VorgangsArtText, VorgangsBeschreibung\n",
    "prop_interest = ['VorgangsTypName', 'VorgangsArtText', 'VorgangsBeschreibung']\n",
    "prop_interest = ['VorgangsArtText', 'VorgangsBeschreibung']\n",
    "prop_interest = ['VorgangsBeschreibung']\n",
    "\n",
    "target_feature_name = 'nlp_model_input'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "8d981bee-2fc9-4ea4-88a5-5589b1d76684",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "timeline:INFO | 2024-05-22 13:45:13 +0000 | Generating concatenation of model input features\n",
      "timeline:INFO | 2024-05-22 13:45:13 +0000 | Model input generated successfully\n"
     ]
    }
   ],
   "source": [
    "anlys_data = generate_model_input(data, target_feature_name, model_input_features=prop_interest)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "616dc58f-f7d7-4787-b662-3900c66c3b64",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Index: 6104 entries, 0 to 123456\n",
      "Data columns (total 21 columns):\n",
      " #   Column                   Non-Null Count  Dtype         \n",
      "---  ------                   --------------  -----         \n",
      " 0   VorgangsID               6104 non-null   int64         \n",
      " 1   ObjektID                 6104 non-null   int64         \n",
      " 2   HObjektText              6103 non-null   object        \n",
      " 3   ObjektArtID              6104 non-null   int64         \n",
      " 4   ObjektArtText            6087 non-null   object        \n",
      " 5   VorgangsTypID            6104 non-null   int64         \n",
      " 6   VorgangsTypName          6104 non-null   object        \n",
      " 7   VorgangsDatum            6104 non-null   datetime64[ns]\n",
      " 8   VorgangsStatusId         6104 non-null   int64         \n",
      " 9   VorgangsPrioritaet       6104 non-null   int64         \n",
      " 10  VorgangsBeschreibung     6104 non-null   object        \n",
      " 11  VorgangsOrt              0 non-null      object        \n",
      " 12  VorgangsArtText          6104 non-null   object        \n",
      " 13  ErledigungsDatum         6104 non-null   datetime64[ns]\n",
      " 14  ErledigungsArtText       6079 non-null   object        \n",
      " 15  ErledigungsBeschreibung  5812 non-null   object        \n",
      " 16  MPMelderArbeitsplatz     5672 non-null   object        \n",
      " 17  MPAbteilungBezeichnung   5672 non-null   object        \n",
      " 18  Arbeitsbeginn            5915 non-null   datetime64[ns]\n",
      " 19  ErstellungsDatum         6104 non-null   datetime64[ns]\n",
      " 20  nlp_model_input          6104 non-null   object        \n",
      "dtypes: datetime64[ns](4), int64(6), object(11)\n",
      "memory usage: 1.0+ MB\n"
     ]
    }
   ],
   "source": [
    "anlys_data.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "5e147157-5710-440e-a787-5f6a6d66bc76",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>VorgangsID</th>\n",
       "      <th>ObjektID</th>\n",
       "      <th>HObjektText</th>\n",
       "      <th>ObjektArtID</th>\n",
       "      <th>ObjektArtText</th>\n",
       "      <th>VorgangsTypID</th>\n",
       "      <th>VorgangsTypName</th>\n",
       "      <th>VorgangsDatum</th>\n",
       "      <th>VorgangsStatusId</th>\n",
       "      <th>VorgangsPrioritaet</th>\n",
       "      <th>...</th>\n",
       "      <th>VorgangsOrt</th>\n",
       "      <th>VorgangsArtText</th>\n",
       "      <th>ErledigungsDatum</th>\n",
       "      <th>ErledigungsArtText</th>\n",
       "      <th>ErledigungsBeschreibung</th>\n",
       "      <th>MPMelderArbeitsplatz</th>\n",
       "      <th>MPAbteilungBezeichnung</th>\n",
       "      <th>Arbeitsbeginn</th>\n",
       "      <th>ErstellungsDatum</th>\n",
       "      <th>nlp_model_input</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>52136</th>\n",
       "      <td>262888</td>\n",
       "      <td>315</td>\n",
       "      <td>NaN</td>\n",
       "      <td>32</td>\n",
       "      <td>Flurförderzeuge / Putzmaschine / Rasenmäher</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2022-07-11</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Flurförderzeug</td>\n",
       "      <td>2022-07-12</td>\n",
       "      <td>Intern UTT - Wartung</td>\n",
       "      <td>Räder gereinigt</td>\n",
       "      <td>Versand</td>\n",
       "      <td>Versand</td>\n",
       "      <td>2022-07-12</td>\n",
       "      <td>2022-07-11</td>\n",
       "      <td>Laufrollen verstopft (Garn)</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1 rows × 21 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       VorgangsID  ObjektID HObjektText  ObjektArtID  \\\n",
       "52136      262888       315         NaN           32   \n",
       "\n",
       "                                     ObjektArtText  VorgangsTypID  \\\n",
       "52136  Flurförderzeuge / Putzmaschine / Rasenmäher              3   \n",
       "\n",
       "                 VorgangsTypName VorgangsDatum  VorgangsStatusId  \\\n",
       "52136  Reparaturauftrag (Portal)    2022-07-11                 5   \n",
       "\n",
       "       VorgangsPrioritaet  ... VorgangsOrt VorgangsArtText ErledigungsDatum  \\\n",
       "52136                   0  ...         NaN  Flurförderzeug       2022-07-12   \n",
       "\n",
       "         ErledigungsArtText ErledigungsBeschreibung MPMelderArbeitsplatz  \\\n",
       "52136  Intern UTT - Wartung         Räder gereinigt              Versand   \n",
       "\n",
       "      MPAbteilungBezeichnung Arbeitsbeginn ErstellungsDatum  \\\n",
       "52136                Versand    2022-07-12       2022-07-11   \n",
       "\n",
       "                   nlp_model_input  \n",
       "52136  Laufrollen verstopft (Garn)  \n",
       "\n",
       "[1 rows x 21 columns]"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "anlys_data.loc[anlys_data['HObjektText'].isna()]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ce40cc45-a2bc-4d84-9688-a4cf2797eecf",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3141fb4b-b861-41fe-a887-fe3a9dbbab9c",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "a08d8f39-d814-4583-b77c-51e660cba6ec",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "ObjektID\n",
       "1       283\n",
       "1654    243\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test = num_activities_per_obj_id.iloc[300:302].copy()\n",
    "test = num_activities_per_obj_id.iloc[:2].copy()\n",
    "test"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "03b9ef0f-0fc9-4e16-bd1c-0774c8c295e8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "366"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test = num_activities_per_obj_id.copy()\n",
    "len(test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "133ad574-7f55-421f-927b-969d26a80ffc",
   "metadata": {},
   "outputs": [],
   "source": [
    "tl_candidates = get_timeline_candidates_index(\n",
    "    data=anlys_data,\n",
    "    num_activities_per_obj_id=test,\n",
    "    model=model_stfr,\n",
    "    cos_sim_threshold=0.8,\n",
    "    model_input_feature=target_feature_name,\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "26085123-1336-4e7f-8b90-68b7c5cb6711",
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "source": [
    "for (obj_id, cands) in tl_candidates:\n",
    "    print(f'{obj_id=}, {cands=}', flush=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "14e2d02b-e24b-4a29-b410-17ef7a0d503d",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "e690e6ff-92a5-48a8-b721-cf78dfe25ab7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "ec2ac9d40ab545d5b6d27b339eeac98e",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "  0%|          | 0/366 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "candidates_by_obj_id = transform_timeline_candidates(tl_candidates)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "04b23a46-a349-4ee2-8910-17e92bf62835",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dict_keys([1, 1654, 7, 151, 140, 20, 21, 1652, 1656, 138, 137, 141, 1808, 22, 1139, 144, 306, 345, 346, 1662, 347, 1663, 405, 337, 336, 69, 1657, 65, 515, 73, 84, 250, 1809, 79, 325, 90, 63, 96, 326, 72, 193, 315, 59, 136, 67, 195, 91, 74, 51, 77, 60, 2166, 186, 76, 100, 121, 78, 2165, 70, 407, 66, 109, 132, 94, 2480, 115, 80, 114, 111, 92, 110, 317, 68, 180, 54, 1126, 318, 108, 58, 107, 47, 98, 113, 81, 181, 119, 309, 127, 53, 75, 95, 218, 120, 149, 123, 183, 135, 116, 255, 152, 57, 388, 319, 44, 148, 316, 89, 625, 220, 64, 338, 145, 175, 698, 52, 129, 241, 182, 895, 122, 41, 259, 404, 214, 167, 153, 2562, 1348, 223, 894, 168, 112, 256, 312, 423, 157, 126, 213, 1659, 184, 432, 216, 281, 170, 1705, 232, 171, 279, 632, 626, 1124, 1152])"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "candidates_by_obj_id.keys()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "49cb06c0-57c7-4bdc-81fd-1462c0735a63",
   "metadata": {},
   "outputs": [],
   "source": [
    "obj_id_to_text = map_obj_texts(\n",
    "    anlys_data, \n",
    "    obj_ids=candidates_by_obj_id.keys(),\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "da4a1d84-296d-4918-a667-f4937c88c962",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{1: '00001, Ausrüstungsanlage 1',\n",
       " 1654: 'WEBEREI ALLGEMEIN, Weberei allgemein',\n",
       " 7: '00007, Ausrüstung 2',\n",
       " 151: '00151, Bandschneidmaschine 4 / Kitamura',\n",
       " 140: '00140, Schlichtmaschine 4 - Sucker',\n",
       " 20: '00020, Lasercutter 2',\n",
       " 21: '00021, Lasercutter 3',\n",
       " 1652: '01652, Vorwerk allgemein',\n",
       " 1656: 'GRUNDSTÜCK UND GEBÄUDE, Grundstück und Gebäude',\n",
       " 138: '00138, Schärmaschine 9',\n",
       " 137: '00137, Schärmaschine 7 - Matthys',\n",
       " 141: '00141, Schlichtmaschine 5 - Sucker',\n",
       " 1808: '01809, Labor allgemein',\n",
       " 22: '00022, Lasercutter 4',\n",
       " 1139: '01139, Ausrüstung 2 / Spannrahmen',\n",
       " 144: '00144, Zettelmaschine 1',\n",
       " 306: 'B04, Ketteinlegewagen',\n",
       " 345: '00348, Warenschautisch 4',\n",
       " 346: '00349, Warenschautisch 5',\n",
       " 1662: 'AUSRÜSTUNG 2 ALLGEMEIN, Ausrüstung 2 allgemein',\n",
       " 347: '00350, Warenschautisch 6',\n",
       " 1663: '01663, Bandschneiderei allgemein',\n",
       " 405: '00405, Assembliermaschine 8',\n",
       " 337: '00337, Bändchenablängmaschine 1',\n",
       " 336: 'B22, Ketteinlegewagen',\n",
       " 69: '448 C , Webmaschine, DL 280 EMS Breite 280 Bj. 04-07',\n",
       " 1657: 'WARENSCHAU ALLGEMEIN, Warenschau allgemein',\n",
       " 65: '434 C , Webmaschine, DL 280 EMS Breite 280 Bj. 04-07',\n",
       " 515: 'B52, Elektro-Kettbaumhubwagen',\n",
       " 73: '444 C , Webmaschine, DL 280 EMS Breite 280 Bj. 04-07',\n",
       " 84: '451 C , Webmaschine, DL 280 EMS Breite 280 Bj. 04-07',\n",
       " 250: '141C, Webmaschine, OM280SOS',\n",
       " 1809: 'LASER ALLGEMEIN, Laser allgemein',\n",
       " 79: '456 C , Webmaschine, DL 280 EMS Breite 280 Bj. 04-07',\n",
       " 325: 'B41, Niederhubwagen',\n",
       " 90: '466 C , Webmaschine, DL 280 EMS Breite 280 Bj. 04-07',\n",
       " 63: '517 C , Webmaschine, DL 280 EMS Breite 280 Bj. 04-07',\n",
       " 96: '474 C , Webmaschine, DL 280 EMS Breite 280 Bj. 04-07',\n",
       " 326: 'B38, Niederhubwagen',\n",
       " 72: '445 C , Webmaschine, DL 280 EMS Breite 280 Bj. 04-07',\n",
       " 193: 'B18, Hochhubwagen',\n",
       " 315: 'B15, Niederhubwagen',\n",
       " 59: '514 C , Webmaschine, DL 280 EMS Breite 280 Bj. 04-07',\n",
       " 136: '00136, Schärmaschine 3 - Benninger',\n",
       " 67: '432 C , Webmaschine, DL 280 EMS Breite 280 Bj. 04-07',\n",
       " 195: 'B36, Niederhubwagen',\n",
       " 91: '467 C , Webmaschine, DL 280 EMS Breite 280 Bj. 04-07',\n",
       " 74: '443 C , Webmaschine, DL 280 EMS Breite 280 Bj. 04-07',\n",
       " 51: '507 C , Webmaschine, DL 280 EMS Breite 280 Bj. 04-07',\n",
       " 77: '458 C , Webmaschine, DL 280 EMS Breite 280 Bj. 04-07',\n",
       " 60: '515 C , Webmaschine, DL 280 EMS Breite 280 Bj. 04-07',\n",
       " 2166: 'A061, Webmaschine Jacquard',\n",
       " 186: '245 J, Webmaschine Jacquard',\n",
       " 76: '441 C , Webmaschine, DL 280 EMS Breite 280 Bj. 04-07',\n",
       " 100: '478 C , Webmaschine, DL 280 EMS Breite 280 Bj. 04-07',\n",
       " 121: '217 C , Webmaschine, DL 280 EMS Breite 280',\n",
       " 78: '457 C , Webmaschine, DL 280 EMS Breite 280 Bj. 04-07',\n",
       " 2165: 'A060, Webmaschine Jacquard',\n",
       " 70: '447 C , Webmaschine, DL 280 EMS Breite 280 Bj. 04-07',\n",
       " 407: '00407, Einziehmaschine Delta 110',\n",
       " 66: '433 C , Webmaschine, DL 280 EMS Breite 280 Bj. 04-07',\n",
       " 109: '422 C , Webmaschine, DL 280 EMS Breite 280',\n",
       " 132: '411 C , Webmaschine, DL 240 EMS',\n",
       " 94: '472 C , Webmaschine, DL 280 EMS Breite 280 Bj. 04-07',\n",
       " 2480: '00352, Ultraschallschweißanlage 1',\n",
       " 115: '415 C , Webmaschine, DL 280 EMS Breite 280',\n",
       " 80: '455 C , Webmaschine, DL 280 EMS Breite 280 Bj. 04-07',\n",
       " 114: '427 C , Webmaschine, DL 280 EMS Breite 280',\n",
       " 111: '424 C , Webmaschine, DL 280 EMS Breite 280',\n",
       " 92: '468 C , Webmaschine, DL 280 EMS Breite 280 Bj. 04-07',\n",
       " 110: '423 C , Webmaschine, DL 280 EMS Breite 280',\n",
       " 317: 'B35, Niederhubwagen',\n",
       " 68: '431 C , Webmaschine, DL 280 EMS Breite 280 Bj. 04-07',\n",
       " 180: '207 C S SI, Webmaschine, DL 280 EMS Breite 220',\n",
       " 54: '504 C , Webmaschine, DL 280 EMS Breite 280 Bj. 04-07',\n",
       " 1126: '01126, Ausrüstung 2 / 0900-Streichmaschine',\n",
       " 318: 'B45, Niederhubwagen',\n",
       " 108: '421 C , Webmaschine, DL 280 EMS Breite 280',\n",
       " 58: '513 C , Webmaschine, DL 280 EMS Breite 280 Bj. 04-07',\n",
       " 107: '437 C , Webmaschine, DL 280 EMS Breite 280',\n",
       " 47: '608 , Webmaschine, DL 190 SOS',\n",
       " 98: '476 C , Webmaschine, DL 280 EMS Breite 280 Bj. 04-07',\n",
       " 113: '426 C , Webmaschine, DL 280 EMS Breite 280',\n",
       " 81: '454 C , Webmaschine, DL 280 EMS Breite 280 Bj. 04-07',\n",
       " 181: '221 C, Webmaschine, DL 280 EMS Breite 280',\n",
       " 119: '215 C , Webmaschine, DL 280 EMS Breite 280',\n",
       " 309: 'B08, Niederhubwagen',\n",
       " 127: '624 C , Webmaschine, DL 280 EMS Breite 280',\n",
       " 53: '505 C , Webmaschine, DL 280 EMS Breite 280 Bj. 04-07',\n",
       " 75: '442 C , Webmaschine, DL 280 EMS Breite 280 Bj. 04-07',\n",
       " 95: '473 C , Webmaschine, DL 280 EMS Breite 280 Bj. 04-07',\n",
       " 218: 'A004, Webmaschine, DL 280 EMS Breite 280',\n",
       " 120: '216 C , Webmaschine, DL 280 EMS Breite 280',\n",
       " 149: '00149, Bandschneidmaschine 2',\n",
       " 123: '620 C , Webmaschine, DL 280 EMS Breite 280',\n",
       " 183: '223 C, Webmaschine, DL 280 EMS Breite 280',\n",
       " 135: '408 C, Webmaschine, DL 240 EMS',\n",
       " 116: '212 C , Webmaschine, DL 280 EMS Breite 280',\n",
       " 255: '105, Webmaschine, OM 220 EOS',\n",
       " 152: 'A001, Webmaschine, DL 280 EMS Breite 280',\n",
       " 57: '512 C , Webmaschine, DL 280 EMS Breite 280 Bj. 04-07',\n",
       " 388: 'H31.1, Deckenlaufkran',\n",
       " 319: 'B47, Niederhubwagen',\n",
       " 44: '605 , Webmaschine, DL 190 SOS',\n",
       " 148: '00148, Bandschneidmaschine 1',\n",
       " 316: 'B34, Niederhubwagen',\n",
       " 89: '465 C , Webmaschine, DL 280 EMS Breite 280 Bj. 04-07',\n",
       " 625: 'R08 , Schnelllauftor',\n",
       " 220: '271 C, Webmaschine, DL 280 EMS Breite 280',\n",
       " 64: '435 C , Webmaschine, DL 280 EMS Breite 280 Bj. 04-07',\n",
       " 338: '00338, Bändchenablängmaschine 2',\n",
       " 145: '00145, Zettelmaschine 2 - Mayer',\n",
       " 175: 'A032 , Webmaschine, DL 280 EMS Breite 280',\n",
       " 698: 'R13, Sektionaltor',\n",
       " 52: '506 C , Webmaschine, DL 280 EMS Breite 280 Bj. 04-07',\n",
       " 129: '626 C , Webmaschine, DL 280 EMS Breite 280',\n",
       " 241: '294 C, Webmaschine, SG 240 EMS',\n",
       " 182: '222 C, Webmaschine, DL 280 EMS Breite 280',\n",
       " 895: 'U25, Ballenpresse',\n",
       " 122: '610 C , Webmaschine, DL 280 EMS Breite 280',\n",
       " 41: '602, Webmaschine, DL 190 SOS',\n",
       " 259: '109, Webmaschine, OM 220 EOS',\n",
       " 404: '00404, Assembliermaschine 6',\n",
       " 214: 'A010, Webmaschine, DL 280 EMS Breite 280',\n",
       " 167: 'A024 , Webmaschine, DL 280 EMS Breite 280',\n",
       " 153: 'A002 , Webmaschine, DL 280 EMS Breite 280',\n",
       " 2562: 'TECHNISCHE ENTWICKLUNG ALLGEMEIN, TECHNISCHE ENTWICKLUNG ALLGEMEIN',\n",
       " 1348: '01348, Filteranlage für Lasercutter 2',\n",
       " 223: '275 C, Webmaschine, DL 280 EMS Breite 280',\n",
       " 894: 'U22, Kippgerät (Versand)',\n",
       " 168: 'A025 , Webmaschine, DL 280 EMS Breite 280',\n",
       " 112: '425 C , Webmaschine, DL 280 EMS Breite 280',\n",
       " 256: '106, Webmaschine, OM 220 EOS',\n",
       " 312: 'B12, Regalbediengerät',\n",
       " 423: '00423, Knotex 2',\n",
       " 157: 'A015 , Webmaschine, DL 280 EMS Breite 280',\n",
       " 126: '623 C , Webmaschine, DL 280 EMS Breite 280',\n",
       " 213: 'A009, Webmaschine, DL 280 EMS Breite 280',\n",
       " 1659: '01659, Laser 3 allgemein',\n",
       " 184: '224 C, Webmaschine, DL 280 EMS Breite 280',\n",
       " 432: 'B02 (ALT), Gabelstapler',\n",
       " 216: 'A012, Webmaschine, DL 280 EMS Breite 280',\n",
       " 281: 'A051, Webmaschine, DL 280 EMS Breite 280',\n",
       " 170: 'A027 , Webmaschine, DL 280 EMS Breite 280',\n",
       " 1705: 'EINZIEHEREI ALLGEMEIN, EINZIEHEREI ALLGEMEIN',\n",
       " 232: '291 C, Webmaschine, SG 240 EMS',\n",
       " 171: 'A028 , Webmaschine, DL 280 EMS Breite 280',\n",
       " 279: 'A049, Webmaschine, DL 280 EMS Breite 280',\n",
       " 632: 'R17 , Schnelllauftor',\n",
       " 626: 'R09 , Schnelllauftor',\n",
       " 1124: '01124, Ausrüstung 2 / 0700-Kühlaggregat',\n",
       " 1152: '01152, Ausrüstung 2 / Strukturdetektor SD 1C Serie 210'}"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "obj_id_to_text"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "d801c7ac-250e-4d22-8a3b-df302f161487",
   "metadata": {},
   "outputs": [],
   "source": [
    "p_data = (p / 'data').with_suffix('.pkl')\n",
    "p_cands = (p / 'map_candidates').with_suffix('.pkl')\n",
    "p_texts = (p / 'map_texts').with_suffix('.pkl')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "dda24ec0-e9ac-40dc-8d1b-c65ff57d21fe",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "shared:INFO | 2024-05-22 13:53:32 +0000 | Saved file successfully under A:\\Arbeitsaufgaben\\lang-main\\test-notebooks\\results\\test_new2\\data.pkl\n",
      "shared:INFO | 2024-05-22 13:53:32 +0000 | Saved file successfully under A:\\Arbeitsaufgaben\\lang-main\\test-notebooks\\results\\test_new2\\map_candidates.pkl\n",
      "shared:INFO | 2024-05-22 13:53:32 +0000 | Saved file successfully under A:\\Arbeitsaufgaben\\lang-main\\test-notebooks\\results\\test_new2\\map_texts.pkl\n"
     ]
    }
   ],
   "source": [
    "save_pickle(anlys_data, p_data)\n",
    "save_pickle(candidates_by_obj_id, p_cands)\n",
    "save_pickle(obj_id_to_text, p_texts)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "401d6b0a-e880-482f-807b-9655ccb64b4b",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "0009cec0-5793-4d4a-991e-3c5268b7eaec",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['VorgangsID', 'ObjektID', 'HObjektText', 'ObjektArtID', 'ObjektArtText',\n",
       "       'VorgangsTypID', 'VorgangsTypName', 'VorgangsDatum', 'VorgangsStatusId',\n",
       "       'VorgangsPrioritaet', 'VorgangsBeschreibung', 'VorgangsOrt',\n",
       "       'VorgangsArtText', 'ErledigungsDatum', 'ErledigungsArtText',\n",
       "       'ErledigungsBeschreibung', 'MPMelderArbeitsplatz',\n",
       "       'MPAbteilungBezeichnung', 'Arbeitsbeginn', 'ErstellungsDatum',\n",
       "       'nlp_model_input'],\n",
       "      dtype='object')"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "anlys_data.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "d4f59a20-d8ba-4d90-a182-56028ddc3515",
   "metadata": {},
   "outputs": [],
   "source": [
    "dashboard_feats = [\n",
    "    'ErstellungsDatum',\n",
    "    'ErledigungsDatum',\n",
    "    'VorgangsTypName',\n",
    "    'VorgangsBeschreibung',\n",
    "]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "6c5459ec-986e-4971-a243-bbb048322f3f",
   "metadata": {},
   "outputs": [],
   "source": [
    "test = anlys_data.iloc[:20].filter(dashboard_feats, axis=1).sort_values(by='ErstellungsDatum', ascending=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "bd86d16e-da54-4c93-a7aa-ea2a32b45600",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0     2019-03-19\n",
       "1     2019-03-21\n",
       "2     2019-03-25\n",
       "6     2019-04-01\n",
       "8     2019-09-09\n",
       "10    2019-09-20\n",
       "12    2019-09-24\n",
       "11    2019-09-25\n",
       "13    2019-10-02\n",
       "14    2019-10-04\n",
       "19    2019-10-27\n",
       "20    2019-11-06\n",
       "21    2019-11-08\n",
       "22    2019-11-13\n",
       "24    2019-11-27\n",
       "25    2019-12-16\n",
       "26    2019-12-19\n",
       "27    2019-12-19\n",
       "36    2020-02-06\n",
       "42    2020-03-10\n",
       "Name: ErstellungsDatum, dtype: object"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test['ErstellungsDatum'].dt.strftime('%Y-%m-%d')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b31aa36e-2d88-4c6c-9820-03a882da70fa",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "88ef77af-ee1b-40a7-bace-16fdd0a28ee7",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "badcab3e-0a87-4623-932c-d4e52a086016",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'ErstellungsDatum': Timestamp('2019-03-19 00:00:00'),\n",
       "  'ErledigungsDatum': Timestamp('2019-03-20 00:00:00'),\n",
       "  'VorgangsTypName': 'Reparaturauftrag (Portal)',\n",
       "  'VorgangsBeschreibung': 'Kupplung schleift'},\n",
       " {'ErstellungsDatum': Timestamp('2019-03-21 00:00:00'),\n",
       "  'ErledigungsDatum': Timestamp('2019-03-21 00:00:00'),\n",
       "  'VorgangsTypName': 'Reparaturauftrag (Portal)',\n",
       "  'VorgangsBeschreibung': 'Gegengewicht wieder anbringen'},\n",
       " {'ErstellungsDatum': Timestamp('2019-03-25 00:00:00'),\n",
       "  'ErledigungsDatum': Timestamp('2019-03-25 00:00:00'),\n",
       "  'VorgangsTypName': 'Reparaturauftrag (Portal)',\n",
       "  'VorgangsBeschreibung': 'da ist etwas gebrochen. (Herr Heininger)'},\n",
       " {'ErstellungsDatum': Timestamp('2019-04-01 00:00:00'),\n",
       "  'ErledigungsDatum': Timestamp('2019-04-08 00:00:00'),\n",
       "  'VorgangsTypName': 'Reparaturauftrag (Portal)',\n",
       "  'VorgangsBeschreibung': 'KBK tauschen\\nUrsache vermutlich mechanisch'},\n",
       " {'ErstellungsDatum': Timestamp('2019-09-09 00:00:00'),\n",
       "  'ErledigungsDatum': Timestamp('2019-09-09 00:00:00'),\n",
       "  'VorgangsTypName': 'Reparaturauftrag (Portal)',\n",
       "  'VorgangsBeschreibung': 'Lager defekt.'},\n",
       " {'ErstellungsDatum': Timestamp('2019-09-20 00:00:00'),\n",
       "  'ErledigungsDatum': Timestamp('2019-09-20 00:00:00'),\n",
       "  'VorgangsTypName': 'Reparaturauftrag (Portal)',\n",
       "  'VorgangsBeschreibung': 'Obere Umlenkwalze Lager Defekt'},\n",
       " {'ErstellungsDatum': Timestamp('2019-09-24 00:00:00'),\n",
       "  'ErledigungsDatum': Timestamp('2019-09-24 00:00:00'),\n",
       "  'VorgangsTypName': 'Reparaturauftrag (Portal)',\n",
       "  'VorgangsBeschreibung': 'Abflussrohr beschädigt'},\n",
       " {'ErstellungsDatum': Timestamp('2019-09-25 00:00:00'),\n",
       "  'ErledigungsDatum': Timestamp('2019-09-26 00:00:00'),\n",
       "  'VorgangsTypName': 'Reparaturauftrag (Portal)',\n",
       "  'VorgangsBeschreibung': 'Bitte DU überprüfen, Verbindung zu Cyclop nicht in Ordnung'},\n",
       " {'ErstellungsDatum': Timestamp('2019-10-02 00:00:00'),\n",
       "  'ErledigungsDatum': Timestamp('2019-10-04 00:00:00'),\n",
       "  'VorgangsTypName': 'Reparaturauftrag (Portal)',\n",
       "  'VorgangsBeschreibung': 'Rad von der Gabel defekt.'},\n",
       " {'ErstellungsDatum': Timestamp('2019-10-04 00:00:00'),\n",
       "  'ErledigungsDatum': Timestamp('2019-10-04 00:00:00'),\n",
       "  'VorgangsTypName': 'Reparaturauftrag (Portal)',\n",
       "  'VorgangsBeschreibung': 'Cyclops scheibe putzen bitte ..'},\n",
       " {'ErstellungsDatum': Timestamp('2019-10-27 00:00:00'),\n",
       "  'ErledigungsDatum': Timestamp('2019-10-28 00:00:00'),\n",
       "  'VorgangsTypName': 'Reparaturauftrag (Portal)',\n",
       "  'VorgangsBeschreibung': 'Zahnriemen erneuern'},\n",
       " {'ErstellungsDatum': Timestamp('2019-11-06 00:00:00'),\n",
       "  'ErledigungsDatum': Timestamp('2019-11-06 00:00:00'),\n",
       "  'VorgangsTypName': 'Reparaturauftrag (Portal)',\n",
       "  'VorgangsBeschreibung': 'Not aus Störung WM:'},\n",
       " {'ErstellungsDatum': Timestamp('2019-11-08 00:00:00'),\n",
       "  'ErledigungsDatum': Timestamp('2019-11-11 00:00:00'),\n",
       "  'VorgangsTypName': 'Reparaturauftrag (Portal)',\n",
       "  'VorgangsBeschreibung': 'beim Verfahren der Scanner kommt ein lautes Quitschgeräusch, bitte kontrollieren und beheben'},\n",
       " {'ErstellungsDatum': Timestamp('2019-11-13 00:00:00'),\n",
       "  'ErledigungsDatum': Timestamp('2019-11-15 00:00:00'),\n",
       "  'VorgangsTypName': 'Reparaturauftrag (Portal)',\n",
       "  'VorgangsBeschreibung': 'Gewinde defekt'},\n",
       " {'ErstellungsDatum': Timestamp('2019-11-27 00:00:00'),\n",
       "  'ErledigungsDatum': Timestamp('2019-11-27 00:00:00'),\n",
       "  'VorgangsTypName': 'Reparaturauftrag (Portal)',\n",
       "  'VorgangsBeschreibung': 'Kugellager an der walze tauschen und walze polieren\\n( am Trittbrett unten)'},\n",
       " {'ErstellungsDatum': Timestamp('2019-12-16 00:00:00'),\n",
       "  'ErledigungsDatum': Timestamp('2019-12-23 00:00:00'),\n",
       "  'VorgangsTypName': 'Reparaturauftrag (Portal)',\n",
       "  'VorgangsBeschreibung': 'Gummi Puffer defekt Bitte neuen bestellen\\n\\nBestellt am 17.12.2019'},\n",
       " {'ErstellungsDatum': Timestamp('2019-12-19 00:00:00'),\n",
       "  'ErledigungsDatum': Timestamp('2019-12-27 00:00:00'),\n",
       "  'VorgangsTypName': 'Reparaturauftrag (Portal)',\n",
       "  'VorgangsBeschreibung': 'Docke walze neu überziehen'},\n",
       " {'ErstellungsDatum': Timestamp('2019-12-19 00:00:00'),\n",
       "  'ErledigungsDatum': Timestamp('2019-12-20 00:00:00'),\n",
       "  'VorgangsTypName': 'Reparaturauftrag (Portal)',\n",
       "  'VorgangsBeschreibung': 'Klemmbrett an neuer Ablage anbringen'},\n",
       " {'ErstellungsDatum': Timestamp('2020-02-06 00:00:00'),\n",
       "  'ErledigungsDatum': Timestamp('2020-02-07 00:00:00'),\n",
       "  'VorgangsTypName': 'Reparaturauftrag (Portal)',\n",
       "  'VorgangsBeschreibung': 'docken belag neu überziehen( gleicher belagtyp)'},\n",
       " {'ErstellungsDatum': Timestamp('2020-03-10 00:00:00'),\n",
       "  'ErledigungsDatum': Timestamp('2020-03-11 00:00:00'),\n",
       "  'VorgangsTypName': 'Reparaturauftrag (Portal)',\n",
       "  'VorgangsBeschreibung': 'Bitte Rau und Kontrawalze überziehen ( gleicher Belag \"Grau Weiß \"'}]"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test.to_dict('records')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "32d39e61-4908-4994-8d64-dabc6d73c443",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b431760b-ac75-4160-903c-65007a25def3",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 228,
   "id": "8748c6a3-6196-42d8-a12c-a92ae7081e30",
   "metadata": {},
   "outputs": [],
   "source": [
    "obj_id = 1654\n",
    "cands = [6696, 113620, 50223]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 229,
   "id": "cee34ab6-6c10-45c7-afaa-9117e8680020",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>VorgangsID</th>\n",
       "      <th>ObjektID</th>\n",
       "      <th>HObjektText</th>\n",
       "      <th>ObjektArtID</th>\n",
       "      <th>ObjektArtText</th>\n",
       "      <th>VorgangsTypID</th>\n",
       "      <th>VorgangsTypName</th>\n",
       "      <th>VorgangsDatum</th>\n",
       "      <th>VorgangsStatusId</th>\n",
       "      <th>VorgangsPrioritaet</th>\n",
       "      <th>...</th>\n",
       "      <th>VorgangsOrt</th>\n",
       "      <th>VorgangsArtText</th>\n",
       "      <th>ErledigungsDatum</th>\n",
       "      <th>ErledigungsArtText</th>\n",
       "      <th>ErledigungsBeschreibung</th>\n",
       "      <th>MPMelderArbeitsplatz</th>\n",
       "      <th>MPAbteilungBezeichnung</th>\n",
       "      <th>Arbeitsbeginn</th>\n",
       "      <th>ErstellungsDatum</th>\n",
       "      <th>nlp_model_input</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>6696</th>\n",
       "      <td>144239</td>\n",
       "      <td>1654</td>\n",
       "      <td>WEBEREI ALLGEMEIN, Weberei allgemein,</td>\n",
       "      <td>90</td>\n",
       "      <td>UTT allgemein</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2021-11-07</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Verkabelung / Verdrahtung</td>\n",
       "      <td>2021-11-08</td>\n",
       "      <td>Intern UTT - Reparatur</td>\n",
       "      <td>Knotex Netzkabel wurde getauscht. Maschine läu...</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>2021-11-08</td>\n",
       "      <td>2021-11-07</td>\n",
       "      <td>Knotex Netzkabel hat einen Wackelkontakt. Kabe...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50223</th>\n",
       "      <td>508708</td>\n",
       "      <td>1654</td>\n",
       "      <td>WEBEREI ALLGEMEIN, Weberei allgemein,</td>\n",
       "      <td>90</td>\n",
       "      <td>UTT allgemein</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2023-01-23</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Verkabelung / Verdrahtung</td>\n",
       "      <td>2023-01-23</td>\n",
       "      <td>Intern UTT - Reparatur</td>\n",
       "      <td>Kabel an Stecker ab, gekürzt alles OK.</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>2023-01-23</td>\n",
       "      <td>2023-01-23</td>\n",
       "      <td>Knotex Netzkabel hat Wackelkontakt.\\nHerr Bric...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>113620</th>\n",
       "      <td>141606</td>\n",
       "      <td>1654</td>\n",
       "      <td>WEBEREI ALLGEMEIN, Weberei allgemein,</td>\n",
       "      <td>90</td>\n",
       "      <td>UTT allgemein</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2021-10-06</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Verkabelung / Verdrahtung</td>\n",
       "      <td>2021-10-06</td>\n",
       "      <td>Intern UTT - Reparatur</td>\n",
       "      <td>Kabel repariert (beide Seiten Wackelkontakt). ...</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>2021-10-06</td>\n",
       "      <td>2021-10-06</td>\n",
       "      <td>Knotex Netzkabel hat Wackelkontakt. Kabel lieg...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3 rows × 21 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        VorgangsID  ObjektID                             HObjektText  \\\n",
       "6696        144239      1654  WEBEREI ALLGEMEIN, Weberei allgemein,    \n",
       "50223       508708      1654  WEBEREI ALLGEMEIN, Weberei allgemein,    \n",
       "113620      141606      1654  WEBEREI ALLGEMEIN, Weberei allgemein,    \n",
       "\n",
       "        ObjektArtID  ObjektArtText  VorgangsTypID            VorgangsTypName  \\\n",
       "6696             90  UTT allgemein              3  Reparaturauftrag (Portal)   \n",
       "50223            90  UTT allgemein              3  Reparaturauftrag (Portal)   \n",
       "113620           90  UTT allgemein              3  Reparaturauftrag (Portal)   \n",
       "\n",
       "       VorgangsDatum  VorgangsStatusId  VorgangsPrioritaet  ... VorgangsOrt  \\\n",
       "6696      2021-11-07                 5                   0  ...         NaN   \n",
       "50223     2023-01-23                 5                   0  ...         NaN   \n",
       "113620    2021-10-06                 5                   0  ...         NaN   \n",
       "\n",
       "                  VorgangsArtText ErledigungsDatum       ErledigungsArtText  \\\n",
       "6696    Verkabelung / Verdrahtung       2021-11-08  Intern UTT - Reparatur    \n",
       "50223   Verkabelung / Verdrahtung       2023-01-23  Intern UTT - Reparatur    \n",
       "113620  Verkabelung / Verdrahtung       2021-10-06  Intern UTT - Reparatur    \n",
       "\n",
       "                                  ErledigungsBeschreibung  \\\n",
       "6696    Knotex Netzkabel wurde getauscht. Maschine läu...   \n",
       "50223              Kabel an Stecker ab, gekürzt alles OK.   \n",
       "113620  Kabel repariert (beide Seiten Wackelkontakt). ...   \n",
       "\n",
       "       MPMelderArbeitsplatz MPAbteilungBezeichnung Arbeitsbeginn  \\\n",
       "6696                Weberei                Weberei    2021-11-08   \n",
       "50223               Weberei                Weberei    2023-01-23   \n",
       "113620              Weberei                Weberei    2021-10-06   \n",
       "\n",
       "       ErstellungsDatum                                    nlp_model_input  \n",
       "6696         2021-11-07  Knotex Netzkabel hat einen Wackelkontakt. Kabe...  \n",
       "50223        2023-01-23  Knotex Netzkabel hat Wackelkontakt.\\nHerr Bric...  \n",
       "113620       2021-10-06  Knotex Netzkabel hat Wackelkontakt. Kabel lieg...  \n",
       "\n",
       "[3 rows x 21 columns]"
      ]
     },
     "execution_count": 229,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "res = anlys_data.loc[cands].sort_index()\n",
    "res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 153,
   "id": "3801daba-6927-44c4-ba22-f0033411372a",
   "metadata": {},
   "outputs": [],
   "source": [
    "import plotly.express as px\n",
    "import plotly.io as pio"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 267,
   "id": "cbc277b4-f77f-4e52-9d3d-845a8dab6169",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.plotly.v1+json": {
       "config": {
        "plotlyServerURL": "https://plot.ly"
       },
       "data": [
        {
         "customdata": [
          [
           "Knotex Netzkabel hat einen Wackelkontakt. Kabel liegt in der Elektrowerkstatt."
          ],
          [
           "Knotex Netzkabel hat Wackelkontakt.\nHerr Brich weiß bescheid"
          ],
          [
           "Knotex Netzkabel hat Wackelkontakt. Kabel liegt in der Elektrowerkstatt auf der Werkbank."
          ]
         ],
         "hovertemplate": "ErstellungsDatum=%{x|%d.%m.%Y}<br>ObjektID=%{y}<br>VorgangsBeschreibung=%{customdata[0]}<extra></extra>",
         "legendgroup": "",
         "line": {
          "color": "#636efa",
          "dash": "solid"
         },
         "marker": {
          "color": "yellow",
          "line": {
           "color": "red",
           "width": 2
          },
          "size": 12,
          "symbol": "diamond"
         },
         "mode": "markers+lines",
         "name": "",
         "orientation": "v",
         "showlegend": false,
         "type": "scatter",
         "x": [
          "2021-11-07T00:00:00",
          "2023-01-23T00:00:00",
          "2021-10-06T00:00:00"
         ],
         "xaxis": "x",
         "y": [
          1654,
          1654,
          1654
         ],
         "yaxis": "y"
        }
       ],
       "layout": {
        "autosize": true,
        "hovermode": "x unified",
        "legend": {
         "tracegroupgap": 0
        },
        "template": {
         "data": {
          "bar": [
           {
            "error_x": {
             "color": "#2a3f5f"
            },
            "error_y": {
             "color": "#2a3f5f"
            },
            "marker": {
             "line": {
              "color": "#E5ECF6",
              "width": 0.5
             },
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "bar"
           }
          ],
          "barpolar": [
           {
            "marker": {
             "line": {
              "color": "#E5ECF6",
              "width": 0.5
             },
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "barpolar"
           }
          ],
          "carpet": [
           {
            "aaxis": {
             "endlinecolor": "#2a3f5f",
             "gridcolor": "white",
             "linecolor": "white",
             "minorgridcolor": "white",
             "startlinecolor": "#2a3f5f"
            },
            "baxis": {
             "endlinecolor": "#2a3f5f",
             "gridcolor": "white",
             "linecolor": "white",
             "minorgridcolor": "white",
             "startlinecolor": "#2a3f5f"
            },
            "type": "carpet"
           }
          ],
          "choropleth": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "type": "choropleth"
           }
          ],
          "contour": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "contour"
           }
          ],
          "contourcarpet": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "type": "contourcarpet"
           }
          ],
          "heatmap": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "heatmap"
           }
          ],
          "heatmapgl": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "heatmapgl"
           }
          ],
          "histogram": [
           {
            "marker": {
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "histogram"
           }
          ],
          "histogram2d": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "histogram2d"
           }
          ],
          "histogram2dcontour": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "histogram2dcontour"
           }
          ],
          "mesh3d": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "type": "mesh3d"
           }
          ],
          "parcoords": [
           {
            "line": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "parcoords"
           }
          ],
          "pie": [
           {
            "automargin": true,
            "type": "pie"
           }
          ],
          "scatter": [
           {
            "fillpattern": {
             "fillmode": "overlay",
             "size": 10,
             "solidity": 0.2
            },
            "type": "scatter"
           }
          ],
          "scatter3d": [
           {
            "line": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatter3d"
           }
          ],
          "scattercarpet": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattercarpet"
           }
          ],
          "scattergeo": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattergeo"
           }
          ],
          "scattergl": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattergl"
           }
          ],
          "scattermapbox": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattermapbox"
           }
          ],
          "scatterpolar": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatterpolar"
           }
          ],
          "scatterpolargl": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatterpolargl"
           }
          ],
          "scatterternary": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatterternary"
           }
          ],
          "surface": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "surface"
           }
          ],
          "table": [
           {
            "cells": {
             "fill": {
              "color": "#EBF0F8"
             },
             "line": {
              "color": "white"
             }
            },
            "header": {
             "fill": {
              "color": "#C8D4E3"
             },
             "line": {
              "color": "white"
             }
            },
            "type": "table"
           }
          ]
         },
         "layout": {
          "annotationdefaults": {
           "arrowcolor": "#2a3f5f",
           "arrowhead": 0,
           "arrowwidth": 1
          },
          "autotypenumbers": "strict",
          "coloraxis": {
           "colorbar": {
            "outlinewidth": 0,
            "ticks": ""
           }
          },
          "colorscale": {
           "diverging": [
            [
             0,
             "#8e0152"
            ],
            [
             0.1,
             "#c51b7d"
            ],
            [
             0.2,
             "#de77ae"
            ],
            [
             0.3,
             "#f1b6da"
            ],
            [
             0.4,
             "#fde0ef"
            ],
            [
             0.5,
             "#f7f7f7"
            ],
            [
             0.6,
             "#e6f5d0"
            ],
            [
             0.7,
             "#b8e186"
            ],
            [
             0.8,
             "#7fbc41"
            ],
            [
             0.9,
             "#4d9221"
            ],
            [
             1,
             "#276419"
            ]
           ],
           "sequential": [
            [
             0,
             "#0d0887"
            ],
            [
             0.1111111111111111,
             "#46039f"
            ],
            [
             0.2222222222222222,
             "#7201a8"
            ],
            [
             0.3333333333333333,
             "#9c179e"
            ],
            [
             0.4444444444444444,
             "#bd3786"
            ],
            [
             0.5555555555555556,
             "#d8576b"
            ],
            [
             0.6666666666666666,
             "#ed7953"
            ],
            [
             0.7777777777777778,
             "#fb9f3a"
            ],
            [
             0.8888888888888888,
             "#fdca26"
            ],
            [
             1,
             "#f0f921"
            ]
           ],
           "sequentialminus": [
            [
             0,
             "#0d0887"
            ],
            [
             0.1111111111111111,
             "#46039f"
            ],
            [
             0.2222222222222222,
             "#7201a8"
            ],
            [
             0.3333333333333333,
             "#9c179e"
            ],
            [
             0.4444444444444444,
             "#bd3786"
            ],
            [
             0.5555555555555556,
             "#d8576b"
            ],
            [
             0.6666666666666666,
             "#ed7953"
            ],
            [
             0.7777777777777778,
             "#fb9f3a"
            ],
            [
             0.8888888888888888,
             "#fdca26"
            ],
            [
             1,
             "#f0f921"
            ]
           ]
          },
          "colorway": [
           "#636efa",
           "#EF553B",
           "#00cc96",
           "#ab63fa",
           "#FFA15A",
           "#19d3f3",
           "#FF6692",
           "#B6E880",
           "#FF97FF",
           "#FECB52"
          ],
          "font": {
           "color": "#2a3f5f"
          },
          "geo": {
           "bgcolor": "white",
           "lakecolor": "white",
           "landcolor": "#E5ECF6",
           "showlakes": true,
           "showland": true,
           "subunitcolor": "white"
          },
          "hoverlabel": {
           "align": "left"
          },
          "hovermode": "closest",
          "mapbox": {
           "style": "light"
          },
          "paper_bgcolor": "white",
          "plot_bgcolor": "#E5ECF6",
          "polar": {
           "angularaxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           },
           "bgcolor": "#E5ECF6",
           "radialaxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           }
          },
          "scene": {
           "xaxis": {
            "backgroundcolor": "#E5ECF6",
            "gridcolor": "white",
            "gridwidth": 2,
            "linecolor": "white",
            "showbackground": true,
            "ticks": "",
            "zerolinecolor": "white"
           },
           "yaxis": {
            "backgroundcolor": "#E5ECF6",
            "gridcolor": "white",
            "gridwidth": 2,
            "linecolor": "white",
            "showbackground": true,
            "ticks": "",
            "zerolinecolor": "white"
           },
           "zaxis": {
            "backgroundcolor": "#E5ECF6",
            "gridcolor": "white",
            "gridwidth": 2,
            "linecolor": "white",
            "showbackground": true,
            "ticks": "",
            "zerolinecolor": "white"
           }
          },
          "shapedefaults": {
           "line": {
            "color": "#2a3f5f"
           }
          },
          "ternary": {
           "aaxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           },
           "baxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           },
           "bgcolor": "#E5ECF6",
           "caxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           }
          },
          "title": {
           "x": 0.05
          },
          "xaxis": {
           "automargin": true,
           "gridcolor": "white",
           "linecolor": "white",
           "ticks": "",
           "title": {
            "standoff": 15
           },
           "zerolinecolor": "white",
           "zerolinewidth": 2
          },
          "yaxis": {
           "automargin": true,
           "gridcolor": "white",
           "linecolor": "white",
           "ticks": "",
           "title": {
            "standoff": 15
           },
           "zerolinecolor": "white",
           "zerolinewidth": 2
          }
         }
        },
        "title": {
         "text": "HObjektText: WEBEREI ALLGEMEIN, Weberei allgemein"
        },
        "xaxis": {
         "anchor": "y",
         "autorange": true,
         "domain": [
          0,
          1
         ],
         "range": [
          "2021-09-06 06:40:56.8194",
          "2023-02-21 17:19:03.1806"
         ],
         "rangeslider": {
          "autorange": true,
          "range": [
           "2021-09-06 06:40:56.8194",
           "2023-02-21 17:19:03.1806"
          ],
          "visible": true,
          "yaxis": {
           "_template": null,
           "rangemode": "match"
          }
         },
         "tickformat": "%B\n%Y",
         "title": {
          "text": "ErstellungsDatum"
         },
         "type": "date"
        },
        "yaxis": {
         "anchor": "x",
         "autorange": true,
         "domain": [
          0,
          1
         ],
         "range": [
          -1,
          1
         ],
         "title": {
          "text": "ObjektID"
         },
         "type": "category"
        }
       }
      },
      "image/png": "[encoded data, 36784 characters]",
      "text/html": [
       "<div>                            <div id=\"64a5454a-ea90-4b06-8393-a5434fc4c859\" class=\"plotly-graph-div\" style=\"height:525px; width:100%;\"></div>            <script type=\"text/javascript\">                require([\"plotly\"], function(Plotly) {                    window.PLOTLYENV=window.PLOTLYENV || {};                                    if (document.getElementById(\"64a5454a-ea90-4b06-8393-a5434fc4c859\")) {                    Plotly.newPlot(                        \"64a5454a-ea90-4b06-8393-a5434fc4c859\",                        [{\"customdata\":[[\"Knotex Netzkabel hat einen Wackelkontakt. Kabel liegt in der Elektrowerkstatt.\"],[\"Knotex Netzkabel hat Wackelkontakt.\\nHerr Brich wei\\u00df bescheid\"],[\"Knotex Netzkabel hat Wackelkontakt. Kabel liegt in der Elektrowerkstatt auf der Werkbank.\"]],\"hovertemplate\":\"ErstellungsDatum=%{x|%d.%m.%Y}\\u003cbr\\u003eObjektID=%{y}\\u003cbr\\u003eVorgangsBeschreibung=%{customdata[0]}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"\",\"line\":{\"color\":\"#636efa\",\"dash\":\"solid\"},\"marker\":{\"symbol\":\"diamond\",\"line\":{\"color\":\"red\",\"width\":2},\"color\":\"yellow\",\"size\":12},\"mode\":\"markers+lines\",\"name\":\"\",\"orientation\":\"v\",\"showlegend\":false,\"x\":[\"2021-11-07T00:00:00\",\"2023-01-23T00:00:00\",\"2021-10-06T00:00:00\"],\"xaxis\":\"x\",\"y\":[1654,1654,1654],\"yaxis\":\"y\",\"type\":\"scatter\"}],                        {\"template\":{\"data\":{\"histogram2dcontour\":[{\"type\":\"histogram2dcontour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"choropleth\":[{\"type\":\"choropleth\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"histogram2d\":[{\"type\":\"histogram2d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmap\":[{\"type\":\"heatmap\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmapgl\":[{\"type\":\"heatmapgl\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"contourcarpet\":[{\"type\":\"contourcarpet\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"contour\":[{\"type\":\"contour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"surface\":[{\"type\":\"surface\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"mesh3d\":[{\"type\":\"mesh3d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"scatter\":[{\"fillpattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2},\"type\":\"scatter\"}],\"parcoords\":[{\"type\":\"parcoords\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolargl\":[{\"type\":\"scatterpolargl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"bar\":[{\"error_x\":{\"color\":\"#2a3f5f\"},\"error_y\":{\"color\":\"#2a3f5f\"},\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"bar\"}],\"scattergeo\":[{\"type\":\"scattergeo\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolar\":[{\"type\":\"scatterpolar\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"histogram\":[{\"marker\":{\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"histogram\"}],\"scattergl\":[{\"type\":\"scattergl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatter3d\":[{\"type\":\"scatter3d\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattermapbox\":[{\"type\":\"scattermapbox\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterternary\":[{\"type\":\"scatterternary\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattercarpet\":[{\"type\":\"scattercarpet\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"carpet\":[{\"aaxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"baxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"type\":\"carpet\"}],\"table\":[{\"cells\":{\"fill\":{\"color\":\"#EBF0F8\"},\"line\":{\"color\":\"white\"}},\"header\":{\"fill\":{\"color\":\"#C8D4E3\"},\"line\":{\"color\":\"white\"}},\"type\":\"table\"}],\"barpolar\":[{\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"barpolar\"}],\"pie\":[{\"automargin\":true,\"type\":\"pie\"}]},\"layout\":{\"autotypenumbers\":\"strict\",\"colorway\":[\"#636efa\",\"#EF553B\",\"#00cc96\",\"#ab63fa\",\"#FFA15A\",\"#19d3f3\",\"#FF6692\",\"#B6E880\",\"#FF97FF\",\"#FECB52\"],\"font\":{\"color\":\"#2a3f5f\"},\"hovermode\":\"closest\",\"hoverlabel\":{\"align\":\"left\"},\"paper_bgcolor\":\"white\",\"plot_bgcolor\":\"#E5ECF6\",\"polar\":{\"bgcolor\":\"#E5ECF6\",\"angularaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"radialaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"ternary\":{\"bgcolor\":\"#E5ECF6\",\"aaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"baxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"caxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"coloraxis\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"colorscale\":{\"sequential\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"sequentialminus\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"diverging\":[[0,\"#8e0152\"],[0.1,\"#c51b7d\"],[0.2,\"#de77ae\"],[0.3,\"#f1b6da\"],[0.4,\"#fde0ef\"],[0.5,\"#f7f7f7\"],[0.6,\"#e6f5d0\"],[0.7,\"#b8e186\"],[0.8,\"#7fbc41\"],[0.9,\"#4d9221\"],[1,\"#276419\"]]},\"xaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"yaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"scene\":{\"xaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"yaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"zaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2}},\"shapedefaults\":{\"line\":{\"color\":\"#2a3f5f\"}},\"annotationdefaults\":{\"arrowcolor\":\"#2a3f5f\",\"arrowhead\":0,\"arrowwidth\":1},\"geo\":{\"bgcolor\":\"white\",\"landcolor\":\"#E5ECF6\",\"subunitcolor\":\"white\",\"showland\":true,\"showlakes\":true,\"lakecolor\":\"white\"},\"title\":{\"x\":0.05},\"mapbox\":{\"style\":\"light\"}}},\"xaxis\":{\"anchor\":\"y\",\"domain\":[0.0,1.0],\"title\":{\"text\":\"ErstellungsDatum\"},\"rangeslider\":{\"visible\":true},\"tickformat\":\"%B\\n%Y\"},\"yaxis\":{\"anchor\":\"x\",\"domain\":[0.0,1.0],\"title\":{\"text\":\"ObjektID\"},\"type\":\"category\"},\"legend\":{\"tracegroupgap\":0},\"title\":{\"text\":\"HObjektText: WEBEREI ALLGEMEIN, Weberei allgemein\"},\"hovermode\":\"x unified\"},                        {\"responsive\": true}                    ).then(function(){\n",
       "                            \n",
       "var gd = document.getElementById('64a5454a-ea90-4b06-8393-a5434fc4c859');\n",
       "var x = new MutationObserver(function (mutations, observer) {{\n",
       "        var display = window.getComputedStyle(gd).display;\n",
       "        if (!display || display === 'none') {{\n",
       "            console.log([gd, 'removed!']);\n",
       "            Plotly.purge(gd);\n",
       "            observer.disconnect();\n",
       "        }}\n",
       "}});\n",
       "\n",
       "// Listen for the removal of the full notebook cells\n",
       "var notebookContainer = gd.closest('#notebook-container');\n",
       "if (notebookContainer) {{\n",
       "    x.observe(notebookContainer, {childList: true});\n",
       "}}\n",
       "\n",
       "// Listen for the clearing of the current output cell\n",
       "var outputEl = gd.closest('.output');\n",
       "if (outputEl) {{\n",
       "    x.observe(outputEl, {childList: true});\n",
       "}}\n",
       "\n",
       "                        })                };                });            </script>        </div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "title = 'HObjektText: TEST'\n",
    "\n",
    "markers = {\n",
    "    'size': 12,\n",
    "    'color': 'yellow',\n",
    "    'line': {\n",
    "        'width': 2,\n",
    "        'color': 'red',\n",
    "    },\n",
    "}\n",
    "hover_data = {\n",
    "    'ErstellungsDatum': '|%d.%m.%Y',\n",
    "    'VorgangsBeschreibung': True,\n",
    "}\n",
    "fig = px.line(\n",
    "    data_frame=res,\n",
    "    x='ErstellungsDatum',\n",
    "    y='ObjektID',\n",
    "    title=title,\n",
    "    hover_data=hover_data,\n",
    ")\n",
    "fig.update_traces(mode='markers+lines', marker=markers, marker_symbol='diamond')\n",
    "fig.update_xaxes(\n",
    "    tickformat=\"%B\\n%Y\",\n",
    "    rangeslider_visible=True,\n",
    ")\n",
    "fig.update_yaxes(type='category')\n",
    "fig.update_layout(hovermode=\"x unified\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8642ade9-30c1-4ac6-8257-9437e2e5e5a1",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5f909534-8a08-42c1-a640-453b0c76d3c9",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
