Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
PythonTutorial
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
SWW
Tutorials
PythonTutorial
Commits
9c53451a
Commit
9c53451a
authored
Nov 20, 2019
by
christian.foerster
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
7cb62627
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
108 additions
and
21 deletions
+108
-21
Numpy.ipynb
Numpy.ipynb
+1
-1
Optimization.ipynb
Optimization.ipynb
+30
-9
Pandas.ipynb
Pandas.ipynb
+54
-2
Python Tutorial - Basics.ipynb
Python Tutorial - Basics.ipynb
+23
-9
No files found.
Numpy.ipynb
View file @
9c53451a
...
...
@@ -311,7 +311,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.
6.8
"
"version": "3.
7.4
"
}
},
"nbformat": 4,
...
...
Optimization.ipynb
View file @
9c53451a
...
...
@@ -46,15 +46,36 @@
"outputs": [],
"source": [
"#renaming columns\n",
"df.columns=[\"h\",\"Q\"]\n",
"\n",
"df.columns=[\"h\",\"Q\"]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# h -> [m], Q -> [m³/s]\n",
"df[\"h\"] = df[\"h\"]/1000\n",
"df[\"Q\"] = df[\"Q\"]/1000\n",
"\n",
"df[\"Q\"] = df[\"Q\"]/1000"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# dropping na's\n",
"df.dropna(how=\"any\",inplace=True)\n",
"\n",
"df.dropna(how=\"any\",inplace=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# removing h<=0, Q<=0\n",
"df = df[(df[\"h\"]>0) & (df[\"Q\"]>0)]"
]
...
...
@@ -223,8 +244,8 @@
"# optimization result!\n",
"kst = result_manning.x[0]\n",
"\n",
"# converting predicted values\n",
"manning_data = df[[\"h\"]]\n",
"# converting predicted values
(creating a new dataframe that contain our manning h and Q)
\n",
"manning_data = df[[\"h\"]]
.copy()
\n",
"manning_data[\"Q\"] = ManningCIR(df.h.values,r,kst,I)\n",
"\n",
"# sorting for plot\n",
...
...
@@ -383,7 +404,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.
6.8
"
"version": "3.
7.4
"
}
},
"nbformat": 4,
...
...
Pandas.ipynb
View file @
9c53451a
...
...
@@ -93,6 +93,23 @@
"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",
"metadata": {},
...
...
@@ -162,6 +179,25 @@
"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",
"metadata": {},
...
...
@@ -189,6 +225,22 @@
"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",
"metadata": {},
...
...
@@ -361,7 +413,7 @@
"outputs": [],
"source": [
"# 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 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.
6.8
"
"version": "3.
7.4
"
}
},
"nbformat": 4,
...
...
Python Tutorial - Basics.ipynb
View file @
9c53451a
...
...
@@ -72,13 +72,6 @@
"a"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Mind the difference between \\/ and \\/\\/**"
]
},
{
"cell_type": "markdown",
"metadata": {},
...
...
@@ -105,6 +98,27 @@
"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",
"metadata": {},
...
...
@@ -632,7 +646,7 @@
"- 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",
"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 comm
e
n values, how would you do it?"
"- If you want to check two large python lists for comm
o
n values, how would you do it?"
]
},
{
...
...
@@ -654,7 +668,7 @@
"# summing up the values of a list\n",
"summe=0\n",
"for num in [1,2,3,4]:\n",
" # everything that is
e
ndeted is within the loop\n",
" # everything that is
i
ndeted is within the loop\n",
" summe+=num\n",
" print(num)\n",
" \n",
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment