Commit f31f173c authored by Johannes Blaschke's avatar Johannes Blaschke

minor cleanups

parent bad80094
Pipeline #5 failed with stages
......@@ -86,7 +86,7 @@
},
{
"cell_type": "code",
"execution_count": 58,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
......@@ -94,26 +94,6 @@
"month_end = lambda dte: date( *next_month( *dte.timetuple()[:3] ) ) - timedelta(days=1)"
]
},
{
"cell_type": "code",
"execution_count": 63,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"datetime.date(2017, 2, 28)"
]
},
"execution_count": 63,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"month_end(d)"
]
},
{
"cell_type": "markdown",
"metadata": {},
......@@ -130,11 +110,11 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"cache_file = \"2017_rates.pickle\"\n",
"cache_file = \"2017_eur.pickle\"\n",
"file_loaded = False\n",
"\n",
"if not os.path.isfile(cache_file):\n",
......@@ -154,7 +134,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
......@@ -178,7 +158,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
......@@ -202,7 +182,7 @@
{
"data": {
"text/plain": [
"[<matplotlib.lines.Line2D at 0x10595a080>]"
"[<matplotlib.lines.Line2D at 0x10e881a20>]"
]
},
"execution_count": 8,
......@@ -247,7 +227,7 @@
},
{
"cell_type": "code",
"execution_count": 32,
"execution_count": 9,
"metadata": {},
"outputs": [
{
......@@ -256,7 +236,7 @@
"45769.452000000005"
]
},
"execution_count": 32,
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
......@@ -268,7 +248,7 @@
},
{
"cell_type": "code",
"execution_count": 33,
"execution_count": 10,
"metadata": {},
"outputs": [
{
......@@ -278,7 +258,7 @@
" 3814.121, 3814.121, 3814.121, 3814.121, 0. , 0. ])"
]
},
"execution_count": 33,
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
......@@ -298,12 +278,12 @@
},
{
"cell_type": "code",
"execution_count": 77,
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"rates_pm = np.zeros_like(in_pm)\n",
"ndays_pm = np.zeros_like(in_pm)\n",
"ndays_pm = np.zeros_like(in_pm, dtype=int)\n",
"for i, _ in enumerate(rates_pm, 1):\n",
" start = date(2017, i, 1)\n",
" end = month_end(start)\n",
......@@ -321,49 +301,29 @@
},
{
"cell_type": "code",
"execution_count": 98,
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0 31.0\n",
"31.0 59.0\n",
"59.0 90.0\n",
"90.0 120.0\n",
"120.0 151.0\n",
"151.0 181.0\n",
"181.0 212.0\n",
"212.0 243.0\n",
"243.0 273.0\n",
"273.0 304.0\n",
"304.0 334.0\n",
"334.0 365.0\n"
]
}
],
"outputs": [],
"source": [
"avg_rates_pd = np.zeros(int(sum(ndays_pm)))\n",
"ct_days = 0 # day counter\n",
"for i, (nday, rate) in enumerate(zip(ndays_pm, rates_pm)):\n",
" print(ct_days, ct_days + nday)\n",
" avg_rates_pd[int(ct_days) : int(ct_days + nday)] = rate * np.ones(int(nday))\n",
" avg_rates_pd[ct_days : ct_days + nday] = rate\n",
" ct_days += nday"
]
},
{
"cell_type": "code",
"execution_count": 100,
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[<matplotlib.lines.Line2D at 0x106b42550>]"
"[<matplotlib.lines.Line2D at 0x10e8fa3c8>]"
]
},
"execution_count": 100,
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
},
......@@ -383,6 +343,26 @@
"plot(avg_rates_pd)"
]
},
{
"cell_type": "code",
"execution_count": 111,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31])"
]
},
"execution_count": 111,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ndays_pm"
]
},
{
"cell_type": "code",
"execution_count": null,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment