refactoring
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
"from DateProvider import DateProvider\n",
|
||||
"from datetime import datetime\n",
|
||||
"from HtmlTransformerUtil import HtmlTransformerUtil\n",
|
||||
"from ColumnsAdder import ColumnsAdder\n",
|
||||
"\n",
|
||||
"pd.set_option('display.max_rows', 100)\n",
|
||||
"pd.set_option('display.max_columns', None)\n",
|
||||
@@ -42,16 +43,6 @@
|
||||
"print(datetime.now().strftime(\"%d.%m.%Y, %H:%M:%S Uhr\"))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "98981ab9",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"os.getcwd()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
@@ -174,40 +165,6 @@
|
||||
"kreise"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "af96fb11",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class ColumnsAdder:\n",
|
||||
"\n",
|
||||
" def __init__(self, kreise):\n",
|
||||
" self.kreise = kreise\n",
|
||||
"\n",
|
||||
" def addKreisAndBundeslandAndEinwohnerzahlColumns(self, dataFrame):\n",
|
||||
" dataFrame = self.addKreisAndEinwohnerzahlColumns(dataFrame)\n",
|
||||
" return self._addBundeslandColumn(dataFrame)\n",
|
||||
" \n",
|
||||
" def addKreisAndEinwohnerzahlColumns(self, dataFrame):\n",
|
||||
" dataFrame_kreise = pd.merge(dataFrame, self.kreise, how = 'left', left_on = 'gemeindeschluessel', right_index = True)\n",
|
||||
" dataFrame['Kreis'] = dataFrame_kreise['Kreis']\n",
|
||||
" dataFrame['Einwohnerzahl'] = dataFrame_kreise['Einwohnerzahl']\n",
|
||||
" return dataFrame\n",
|
||||
"\n",
|
||||
" def _addBundeslandColumn(self, dataFrame):\n",
|
||||
" return pd.merge(\n",
|
||||
" dataFrame,\n",
|
||||
" self._createBundeslandByKeyTable(),\n",
|
||||
" how = 'left',\n",
|
||||
" left_on = 'bundesland',\n",
|
||||
" right_index = True)\n",
|
||||
"\n",
|
||||
" def _createBundeslandByKeyTable(self):\n",
|
||||
" return self.kreise[self.kreise.index.str.len() == 2][['Bundesland']]\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
|
||||
Reference in New Issue
Block a user