Add link to .csv-file to import

pull/10/head
Tim Skov Jacobsen 2020-02-03 09:55:46 +01:00
parent d1c15f682a
commit 76848cee3d
1 changed files with 44 additions and 42 deletions

View File

@ -14,7 +14,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
@ -31,7 +31,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 4,
"metadata": {},
"outputs": [
{
@ -90,7 +90,7 @@
"2 13 23 33"
]
},
"execution_count": 2,
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
@ -115,7 +115,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 5,
"metadata": {},
"outputs": [
{
@ -144,7 +144,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 6,
"metadata": {},
"outputs": [
{
@ -203,7 +203,7 @@
"2 120 314 0.382166"
]
},
"execution_count": 4,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
@ -236,7 +236,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 7,
"metadata": {},
"outputs": [
{
@ -302,7 +302,7 @@
"3 120 314 0.382166"
]
},
"execution_count": 5,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
@ -327,7 +327,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 8,
"metadata": {},
"outputs": [
{
@ -383,7 +383,7 @@
"3 0.382166"
]
},
"execution_count": 6,
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
@ -402,7 +402,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 9,
"metadata": {},
"outputs": [
{
@ -415,7 +415,7 @@
"Name: sigma_n [GPa], dtype: float64"
]
},
"execution_count": 7,
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
@ -436,7 +436,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 10,
"metadata": {},
"outputs": [
{
@ -497,7 +497,7 @@
"3 120 0.382166"
]
},
"execution_count": 8,
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
@ -556,7 +556,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 11,
"metadata": {},
"outputs": [
{
@ -707,7 +707,7 @@
"10 HE300A 290 300 182600000 1260.0 88.3"
]
},
"execution_count": 9,
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
@ -730,7 +730,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 12,
"metadata": {},
"outputs": [
{
@ -831,7 +831,7 @@
"10 HE300A 290 300 182600000 1260.0 88.3"
]
},
"execution_count": 10,
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
@ -857,7 +857,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 13,
"metadata": {},
"outputs": [
{
@ -877,7 +877,7 @@
"Name: Iy[mm4], dtype: bool"
]
},
"execution_count": 11,
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
@ -901,7 +901,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 14,
"metadata": {},
"outputs": [
{
@ -982,7 +982,7 @@
"8 HE260A 250 260 104500000 836.0 68.2"
]
},
"execution_count": 12,
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
@ -1007,7 +1007,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 15,
"metadata": {},
"outputs": [
{
@ -1078,7 +1078,7 @@
"9 HE280A 270 280 136700000 1010.0 76.4"
]
},
"execution_count": 13,
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
@ -1102,7 +1102,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 16,
"metadata": {},
"outputs": [
{
@ -1173,7 +1173,7 @@
"10 HE300A 290 300 182600000 1260.0 88.3"
]
},
"execution_count": 14,
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
@ -1214,7 +1214,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 17,
"metadata": {},
"outputs": [
{
@ -1299,7 +1299,7 @@
"7 Pear 6"
]
},
"execution_count": 15,
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
@ -1321,16 +1321,16 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<pandas.core.groupby.generic.DataFrameGroupBy object at 0x000001C6E0EC2388>"
"<pandas.core.groupby.generic.DataFrameGroupBy object at 0x000001EC320855C8>"
]
},
"execution_count": 16,
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
@ -1351,7 +1351,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 19,
"metadata": {},
"outputs": [
{
@ -1412,7 +1412,7 @@
"Pear 9"
]
},
"execution_count": 17,
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
@ -1583,16 +1583,18 @@
"***All exercises 2.x are to be seen as the same problem. It has just been divided into smaller tasks.***\n",
"\n",
"---\n",
"Import the file `shear_key_forces.csv` to a DataFrame using `pandas.read_csv()`. The values in the file are comma separated, which the function also assumes as default. \n",
"The file is located in the Session 5 folder and has 104329 rows. Print the head or the tail to see the imported data.\n",
"This exercise works with a file called `shear_key_forces.csv`. To get the file go [here](https://raw.githubusercontent.com/Python-Crash-Course/Python101/master/Session%205%20-%20Dataframes/shear_key_forces.csv), right-click and choose \"save as\". Select `.csv` as file format. Save the file in the same folder as your script for this exercise. \n",
"\n",
"Inside your script, import the file `shear_key_forces.csv` to a DataFrame using `pandas.read_csv()`. The values in the file are comma separated, which the function also assumes as default. \n",
"The file has 104329 rows. Print the head or the tail to see the imported data.\n",
"\n",
"*The data has all spring element forces in a bunch of load cases from a Sofistik finite element calculation. It's not strictly necessary to know what the data represents. It could just be looked at as dummy data to work with.*\n",
"\n",
"\n",
"# Exercise 2.2\n",
"*The model has many spring elements. Some of them represent shear keys between the structural parts of a tunnel at movement joint locations. These are the one we are going to extract.*\n",
"*The model has many spring elements. Some of them represent shear keys between the structural parts of a tunnel at movement joint locations. These are the ones we are going to extract.*\n",
"\n",
"The data has a column `'shear_key'` which has the name of the shear key if the element in that row is part of a shear key. E.g. `'Shear_key1'`. If the element is not part of a shear key, the name is `'Not_a_shear_key'`.\n",
"The data has a column `'shear_key'` which has the name of the shear key if the element in that row is part of a shear key in the model. E.g. `'Shear_key1'`. If the element is not part of a shear key, the name is `'Not_a_shear_key'`.\n",
"\n",
"Filter out all rows which are not part of a shear key. The resulting DataFrame should have 2874 rows. \n",
"\n",
@ -1606,13 +1608,13 @@
"df = df.drop('column_name', axis=1)\n",
"~~~\n",
"---\n",
"The argument `axis=1` specifies that it is a column and not a row that should be removed.\n",
"The argument `axis=1` specifies that it is a column that should be removed, whereas `axis=0` would represent removal of a row.\n",
"\n",
"*Remember to save to a new variable or use argument `inplace=True`. If you save to a variable, you can use the same name to 'overwrite' the old one if it's not needed anymore.*\n",
"\n",
"\n",
"# Exercise 2.4\n",
"*Each shear key consists of three spring elements. The total force that the shear key should be designed for is the sum of those three spring forces.*\n",
"*Each shear key consists of three spring elements. The total force in the shear key is the sum of those three spring forces.*\n",
"\n",
"Create a DataFrame with the sum of the three values within each shear key for every load case. The resulting DataFrame should have 958 rows.\n",
"\n",
@ -1627,7 +1629,7 @@
"Here, a list of column labels is passed in the `groupby()` method instead of just a single column label. The first column `'Shear_key'` is what is used to create the groups, while consecutive labels just follow. Any columns that are not passed in will not appear in the resulting DataFrame. \n",
"\n",
"# Exercise 2.5\n",
"Filter the DataFrame for a shear key, for example `'Shear_key1'` and create a bar plot of it with the `DataFrame.plot()` method. The bar plot should have the load cases as $x$-values and the force $P$ [kN] as $y$-values.\n",
"Filter the DataFrame for a specific shear key, for example `'Shear_key1'` and create a bar plot of it with the `DataFrame.plot()` method. The bar plot should have the load cases as $x$-values and the force $P$ [kN] as $y$-values.\n",
"\n",
"---\n",
"~~~python\n",
@ -1655,7 +1657,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 20,
"metadata": {},
"outputs": [
{
@ -1928,7 +1930,7 @@
"<IPython.core.display.HTML object>"
]
},
"execution_count": 18,
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}