Skip to content

Commit

Permalink
[#43] Cache downloaded data; Implement feature with decorator; added …
Browse files Browse the repository at this point in the history
…tests
  • Loading branch information
pmayd committed Aug 1, 2022
1 parent 1779053 commit 350ecb7
Show file tree
Hide file tree
Showing 10 changed files with 502 additions and 195 deletions.
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ignore=third_party

# Files or directories matching the regex patterns are skipped. The regex
# matches against base names, not paths.
ignore-patterns=
ignore-patterns=test_.*

# Pickle collected data for later comparisons.
persistent=no
Expand Down
201 changes: 201 additions & 0 deletions nb/download_cubefile.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "69e1d305",
"metadata": {},
"outputs": [],
"source": [
"%load_ext autoreload\n",
"%autoreload 2"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "ff9eca4f",
"metadata": {},
"outputs": [],
"source": [
"# only if you get an error from below\n",
"# from pygenesis import init_config\n",
"# init_config()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "4a207a77",
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"\n",
"from pygenesis.cube import get_cubefile_data"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "6e6df177",
"metadata": {},
"outputs": [],
"source": [
"params = {\"values\": \"true\", \"metadata\": \"true\", \"additionals\": \"false\"}\n",
"data = get_cubefile_data(name=\"47414BJ002\", **params)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "a8bcd5b4",
"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>DINSG</th>\n",
" <th>WZ08N7</th>\n",
" <th>WERTE4</th>\n",
" <th>JAHR</th>\n",
" <th>UMS103</th>\n",
" <th>QUALITAET</th>\n",
" <th>GESPERRT</th>\n",
" <th>WERT-VERFAELSCHT</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>DG</td>\n",
" <td>WZ08-49-01</td>\n",
" <td>NOMINAL</td>\n",
" <td>2015</td>\n",
" <td>100.0</td>\n",
" <td>e</td>\n",
" <td>NaN</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>DG</td>\n",
" <td>WZ08-49-01</td>\n",
" <td>NOMINAL</td>\n",
" <td>2016</td>\n",
" <td>99.3</td>\n",
" <td>e</td>\n",
" <td>NaN</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>DG</td>\n",
" <td>WZ08-49-01</td>\n",
" <td>NOMINAL</td>\n",
" <td>2017</td>\n",
" <td>105.7</td>\n",
" <td>e</td>\n",
" <td>NaN</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>DG</td>\n",
" <td>WZ08-49-01</td>\n",
" <td>NOMINAL</td>\n",
" <td>2018</td>\n",
" <td>111.6</td>\n",
" <td>e</td>\n",
" <td>NaN</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>DG</td>\n",
" <td>WZ08-49-01</td>\n",
" <td>NOMINAL</td>\n",
" <td>2019</td>\n",
" <td>115.6</td>\n",
" <td>e</td>\n",
" <td>NaN</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" DINSG WZ08N7 WERTE4 JAHR UMS103 QUALITAET GESPERRT \\\n",
"0 DG WZ08-49-01 NOMINAL 2015 100.0 e NaN \n",
"1 DG WZ08-49-01 NOMINAL 2016 99.3 e NaN \n",
"2 DG WZ08-49-01 NOMINAL 2017 105.7 e NaN \n",
"3 DG WZ08-49-01 NOMINAL 2018 111.6 e NaN \n",
"4 DG WZ08-49-01 NOMINAL 2019 115.6 e NaN \n",
"\n",
" WERT-VERFAELSCHT \n",
"0 0.0 \n",
"1 0.0 \n",
"2 0.0 \n",
"3 0.0 \n",
"4 0.0 "
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data.head()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "fed610c9",
"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.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
14 changes: 3 additions & 11 deletions nb/download_tablefile.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,7 @@
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Error while loading the config file. Could not find C:\\Users\\micha\\AppData\\Local\\Temp\\pytest-of-micha\\pytest-78\\.pygenesis3\\config.ini. Please make sure to run init_config() first. \n"
]
}
],
"outputs": [],
"source": [
"import pandas as pd\n",
"from pygenesis.table import get_tablefile_data"
Expand All @@ -44,13 +36,13 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 4,
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"data = get_tablefile_data(\"61111-0002\", table_area=all)"
"data = get_tablefile_data(name=\"61111-0002\", table_area=all)"
]
},
{
Expand Down
Loading

0 comments on commit 350ecb7

Please sign in to comment.