Commit 9c53451a authored by christian.foerster's avatar christian.foerster

update

parent 7cb62627
...@@ -311,7 +311,7 @@ ...@@ -311,7 +311,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.6.8" "version": "3.7.4"
} }
}, },
"nbformat": 4, "nbformat": 4,
......
...@@ -46,15 +46,36 @@ ...@@ -46,15 +46,36 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"#renaming columns\n", "#renaming columns\n",
"df.columns=[\"h\",\"Q\"]\n", "df.columns=[\"h\",\"Q\"]"
"\n", ]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# h -> [m], Q -> [m³/s]\n", "# h -> [m], Q -> [m³/s]\n",
"df[\"h\"] = df[\"h\"]/1000\n", "df[\"h\"] = df[\"h\"]/1000\n",
"df[\"Q\"] = df[\"Q\"]/1000\n", "df[\"Q\"] = df[\"Q\"]/1000"
"\n", ]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# dropping na's\n", "# dropping na's\n",
"df.dropna(how=\"any\",inplace=True)\n", "df.dropna(how=\"any\",inplace=True)"
"\n", ]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# removing h<=0, Q<=0\n", "# removing h<=0, Q<=0\n",
"df = df[(df[\"h\"]>0) & (df[\"Q\"]>0)]" "df = df[(df[\"h\"]>0) & (df[\"Q\"]>0)]"
] ]
...@@ -223,8 +244,8 @@ ...@@ -223,8 +244,8 @@
"# optimization result!\n", "# optimization result!\n",
"kst = result_manning.x[0]\n", "kst = result_manning.x[0]\n",
"\n", "\n",
"# converting predicted values\n", "# converting predicted values (creating a new dataframe that contain our manning h and Q)\n",
"manning_data = df[[\"h\"]]\n", "manning_data = df[[\"h\"]].copy()\n",
"manning_data[\"Q\"] = ManningCIR(df.h.values,r,kst,I)\n", "manning_data[\"Q\"] = ManningCIR(df.h.values,r,kst,I)\n",
"\n", "\n",
"# sorting for plot\n", "# sorting for plot\n",
...@@ -383,7 +404,7 @@ ...@@ -383,7 +404,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.6.8" "version": "3.7.4"
} }
}, },
"nbformat": 4, "nbformat": 4,
......
...@@ -93,6 +93,23 @@ ...@@ -93,6 +93,23 @@
"df2" "df2"
] ]
}, },
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Task 1 \n",
"\n",
"Create a Dataframe from a list.\n",
"Call the DataFrame **df_mine**."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
...@@ -162,6 +179,25 @@ ...@@ -162,6 +179,25 @@
"print(df[[\"a\",\"b\"]][:3])\n" "print(df[[\"a\",\"b\"]][:3])\n"
] ]
}, },
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Task 2\n",
"\n",
"Play around with indexing:\n",
"- try to get a column\n",
"- try to get row\n",
"- try to get a cell"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
...@@ -189,6 +225,22 @@ ...@@ -189,6 +225,22 @@
"plt.tight_layout()" "plt.tight_layout()"
] ]
}, },
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Task 3\n",
"\n",
"Plot column 'a' with a title!"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
...@@ -361,7 +413,7 @@ ...@@ -361,7 +413,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# column bind (axis=1) (row bind axis=0)\n", "# column bind (axis=1) (row bind axis=0)\n",
"newdf=pd.concat([df[\"A\"],df[\"exponential_column\"]],axis=1)" "newdf=pd.concat([df[\"a\"],df[\"exponential_column\"]],axis=1)"
] ]
}, },
{ {
...@@ -595,7 +647,7 @@ ...@@ -595,7 +647,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.6.8" "version": "3.7.4"
} }
}, },
"nbformat": 4, "nbformat": 4,
......
...@@ -72,13 +72,6 @@ ...@@ -72,13 +72,6 @@
"a" "a"
] ]
}, },
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Mind the difference between \\/ and \\/\\/**"
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
...@@ -105,6 +98,27 @@ ...@@ -105,6 +98,27 @@
"print(r\"C:\\adg\\ggj\")" "print(r\"C:\\adg\\ggj\")"
] ]
}, },
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'42323dsfdsagfdsafsa .. . .99.900'"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"2**99%57\n",
"\"42323dsfdsagfdsafsa .. . .%.3f\" %99.9"
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
...@@ -632,7 +646,7 @@ ...@@ -632,7 +646,7 @@
"- What's the remainder of $2^{99}$ divided by $57$? \n", "- What's the remainder of $2^{99}$ divided by $57$? \n",
"- If you were to write a little database, that gets one file for every day containing data for that day. \n", "- If you were to write a little database, that gets one file for every day containing data for that day. \n",
"And you want to store the file locations in a basic python data structure. Which one would you use and why? \n", "And you want to store the file locations in a basic python data structure. Which one would you use and why? \n",
"- If you want to check two large python lists for commen values, how would you do it?" "- If you want to check two large python lists for common values, how would you do it?"
] ]
}, },
{ {
...@@ -654,7 +668,7 @@ ...@@ -654,7 +668,7 @@
"# summing up the values of a list\n", "# summing up the values of a list\n",
"summe=0\n", "summe=0\n",
"for num in [1,2,3,4]:\n", "for num in [1,2,3,4]:\n",
" # everything that is endeted is within the loop\n", " # everything that is indeted is within the loop\n",
" summe+=num\n", " summe+=num\n",
" print(num)\n", " print(num)\n",
" \n", " \n",
......
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