Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .ipynb_checkpoints/test-checkpoint.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 4
}
2 changes: 1 addition & 1 deletion .ipynb_checkpoints/w2-checkpoint.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"First, we will go through **numpy** arrays!"
"First, we will go through **numpy** arrays!!"
]
},
{
Expand Down
59 changes: 59 additions & 0 deletions test.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"6\n"
]
}
],
"source": [
"x = 4 + 2\n",
"print(x)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
223 changes: 21 additions & 202 deletions w3/w2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"First, we will go through **numpy** arrays!"
"First, we will go through **numpy** arrays!!"
]
},
{
Expand Down Expand Up @@ -65,7 +65,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 4,
"metadata": {},
"outputs": [
{
Expand All @@ -74,7 +74,7 @@
"array([3, 2, 3])"
]
},
"execution_count": 8,
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -159,7 +159,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"**How to import a csv jupyter**\n",
"**How to import a csv file to a jupyter notebook**\n",
"\n",
"\n",
"Here I am importing a csv file to jupyter. It is important to know how to import these files to python because all our data are going to be written into csv files hereafter. Note that I have imported a library called pandas. It is a python library that\n",
Expand All @@ -168,209 +168,28 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 5,
"metadata": {
"scrolled": true
},
"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>Shape1x</th>\n",
" <th>Shape1y</th>\n",
" <th>Shape2x</th>\n",
" <th>Shape2y</th>\n",
" <th>Shape3x</th>\n",
" <th>Shape3y</th>\n",
" <th>Shape4x</th>\n",
" <th>Shape4y</th>\n",
" <th>Shape5x</th>\n",
" <th>Shape5y</th>\n",
" <th>...</th>\n",
" <th>Shape11x</th>\n",
" <th>Shape11y</th>\n",
" <th>Shape12x</th>\n",
" <th>Shape12y</th>\n",
" <th>Shape13x</th>\n",
" <th>Shape13y</th>\n",
" <th>Shape14x</th>\n",
" <th>Shape14y</th>\n",
" <th>Shape15x</th>\n",
" <th>Shape15y</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>-6.0</td>\n",
" <td>-15.5</td>\n",
" <td>-5.5</td>\n",
" <td>-13.5</td>\n",
" <td>-5.0</td>\n",
" <td>-15.0</td>\n",
" <td>5.5</td>\n",
" <td>-10.5</td>\n",
" <td>-5.0</td>\n",
" <td>-14.0</td>\n",
" <td>...</td>\n",
" <td>5.5</td>\n",
" <td>8.5</td>\n",
" <td>1.5</td>\n",
" <td>10.0</td>\n",
" <td>-0.5</td>\n",
" <td>9.5</td>\n",
" <td>-3.0</td>\n",
" <td>7.0</td>\n",
" <td>0.5</td>\n",
" <td>6.5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>-6.0</td>\n",
" <td>-17.0</td>\n",
" <td>-5.5</td>\n",
" <td>-14.5</td>\n",
" <td>-5.0</td>\n",
" <td>-14.0</td>\n",
" <td>6.5</td>\n",
" <td>-10.5</td>\n",
" <td>-5.5</td>\n",
" <td>-13.5</td>\n",
" <td>...</td>\n",
" <td>5.0</td>\n",
" <td>9.5</td>\n",
" <td>1.5</td>\n",
" <td>11.0</td>\n",
" <td>-0.5</td>\n",
" <td>11.5</td>\n",
" <td>-1.0</td>\n",
" <td>6.5</td>\n",
" <td>1.0</td>\n",
" <td>5.5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>-7.5</td>\n",
" <td>-17.5</td>\n",
" <td>-8.0</td>\n",
" <td>-15.5</td>\n",
" <td>-3.0</td>\n",
" <td>-12.5</td>\n",
" <td>6.5</td>\n",
" <td>-14.0</td>\n",
" <td>-6.0</td>\n",
" <td>-13.0</td>\n",
" <td>...</td>\n",
" <td>4.0</td>\n",
" <td>9.5</td>\n",
" <td>-0.5</td>\n",
" <td>12.0</td>\n",
" <td>-0.5</td>\n",
" <td>13.0</td>\n",
" <td>-0.5</td>\n",
" <td>6.0</td>\n",
" <td>2.0</td>\n",
" <td>5.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>-7.5</td>\n",
" <td>-16.0</td>\n",
" <td>-8.0</td>\n",
" <td>-18.5</td>\n",
" <td>-2.0</td>\n",
" <td>-13.0</td>\n",
" <td>4.0</td>\n",
" <td>-15.0</td>\n",
" <td>-6.0</td>\n",
" <td>-11.0</td>\n",
" <td>...</td>\n",
" <td>1.5</td>\n",
" <td>10.0</td>\n",
" <td>0.0</td>\n",
" <td>12.5</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>0.0</td>\n",
" <td>6.0</td>\n",
" <td>2.5</td>\n",
" <td>5.5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>-6.0</td>\n",
" <td>-15.5</td>\n",
" <td>-5.5</td>\n",
" <td>-17.5</td>\n",
" <td>0.0</td>\n",
" <td>-13.5</td>\n",
" <td>0.0</td>\n",
" <td>-15.5</td>\n",
" <td>-5.0</td>\n",
" <td>-11.0</td>\n",
" <td>...</td>\n",
" <td>-0.5</td>\n",
" <td>9.5</td>\n",
" <td>0.5</td>\n",
" <td>13.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>0.5</td>\n",
" <td>6.5</td>\n",
" <td>3.0</td>\n",
" <td>6.5</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>5 rows × 30 columns</p>\n",
"</div>"
],
"text/plain": [
" Shape1x Shape1y Shape2x Shape2y Shape3x Shape3y Shape4x Shape4y \\\n",
"0 -6.0 -15.5 -5.5 -13.5 -5.0 -15.0 5.5 -10.5 \n",
"1 -6.0 -17.0 -5.5 -14.5 -5.0 -14.0 6.5 -10.5 \n",
"2 -7.5 -17.5 -8.0 -15.5 -3.0 -12.5 6.5 -14.0 \n",
"3 -7.5 -16.0 -8.0 -18.5 -2.0 -13.0 4.0 -15.0 \n",
"4 -6.0 -15.5 -5.5 -17.5 0.0 -13.5 0.0 -15.5 \n",
"\n",
" Shape5x Shape5y ... Shape11x Shape11y Shape12x Shape12y Shape13x \\\n",
"0 -5.0 -14.0 ... 5.5 8.5 1.5 10.0 -0.5 \n",
"1 -5.5 -13.5 ... 5.0 9.5 1.5 11.0 -0.5 \n",
"2 -6.0 -13.0 ... 4.0 9.5 -0.5 12.0 -0.5 \n",
"3 -6.0 -11.0 ... 1.5 10.0 0.0 12.5 NaN \n",
"4 -5.0 -11.0 ... -0.5 9.5 0.5 13.0 NaN \n",
"\n",
" Shape13y Shape14x Shape14y Shape15x Shape15y \n",
"0 9.5 -3.0 7.0 0.5 6.5 \n",
"1 11.5 -1.0 6.5 1.0 5.5 \n",
"2 13.0 -0.5 6.0 2.0 5.0 \n",
"3 NaN 0.0 6.0 2.5 5.5 \n",
"4 NaN 0.5 6.5 3.0 6.5 \n",
"\n",
"[5 rows x 30 columns]"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
"ename": "FileNotFoundError",
"evalue": "[Errno 2] File C:\\Users\\kanee\\Desktop\\KIM LAB\\Coding Sessions\\W2\\sd.csv does not exist: 'C:\\\\Users\\\\kanee\\\\Desktop\\\\KIM LAB\\\\Coding Sessions\\\\W2\\\\sd.csv'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-5-3841656396cd>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mdf\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mpd\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mread_csv\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34mr'C:\\Users\\kanee\\Desktop\\KIM LAB\\Coding Sessions\\W2\\sd.csv'\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m#here copy and paste the path where the 'sd.csv'\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0;31m#file is. Note that I am assigning the name df to the new pandas dataframe. #the path should be between '(path...)'\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mdf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mhead\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m#this function just print out the first few rows of the dataframe. I am not sure if there is a way to look up all the\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;31m#rows. Please open the csv file and make sure you know how the data is arranged in the excel file and in the pandas DataFrame.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/anaconda3/lib/python3.7/site-packages/pandas/io/parsers.py\u001b[0m in \u001b[0;36mparser_f\u001b[0;34m(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, dialect, error_bad_lines, warn_bad_lines, delim_whitespace, low_memory, memory_map, float_precision)\u001b[0m\n\u001b[1;32m 674\u001b[0m )\n\u001b[1;32m 675\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 676\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0m_read\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfilepath_or_buffer\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkwds\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 677\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 678\u001b[0m \u001b[0mparser_f\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__name__\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/anaconda3/lib/python3.7/site-packages/pandas/io/parsers.py\u001b[0m in \u001b[0;36m_read\u001b[0;34m(filepath_or_buffer, kwds)\u001b[0m\n\u001b[1;32m 446\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 447\u001b[0m \u001b[0;31m# Create the parser.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 448\u001b[0;31m \u001b[0mparser\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mTextFileReader\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfp_or_buf\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwds\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 449\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 450\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mchunksize\u001b[0m \u001b[0;32mor\u001b[0m \u001b[0miterator\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/anaconda3/lib/python3.7/site-packages/pandas/io/parsers.py\u001b[0m in \u001b[0;36m__init__\u001b[0;34m(self, f, engine, **kwds)\u001b[0m\n\u001b[1;32m 878\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0moptions\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"has_index_names\"\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mkwds\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"has_index_names\"\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 879\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 880\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_make_engine\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mengine\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 881\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 882\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mclose\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/anaconda3/lib/python3.7/site-packages/pandas/io/parsers.py\u001b[0m in \u001b[0;36m_make_engine\u001b[0;34m(self, engine)\u001b[0m\n\u001b[1;32m 1112\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m_make_engine\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mengine\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"c\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1113\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mengine\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;34m\"c\"\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1114\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_engine\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mCParserWrapper\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mf\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0moptions\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1115\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1116\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mengine\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;34m\"python\"\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/anaconda3/lib/python3.7/site-packages/pandas/io/parsers.py\u001b[0m in \u001b[0;36m__init__\u001b[0;34m(self, src, **kwds)\u001b[0m\n\u001b[1;32m 1889\u001b[0m \u001b[0mkwds\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"usecols\"\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0musecols\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1890\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1891\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_reader\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mparsers\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mTextReader\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msrc\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwds\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1892\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0munnamed_cols\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_reader\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0munnamed_cols\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1893\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32mpandas/_libs/parsers.pyx\u001b[0m in \u001b[0;36mpandas._libs.parsers.TextReader.__cinit__\u001b[0;34m()\u001b[0m\n",
"\u001b[0;32mpandas/_libs/parsers.pyx\u001b[0m in \u001b[0;36mpandas._libs.parsers.TextReader._setup_parser_source\u001b[0;34m()\u001b[0m\n",
"\u001b[0;31mFileNotFoundError\u001b[0m: [Errno 2] File C:\\Users\\kanee\\Desktop\\KIM LAB\\Coding Sessions\\W2\\sd.csv does not exist: 'C:\\\\Users\\\\kanee\\\\Desktop\\\\KIM LAB\\\\Coding Sessions\\\\W2\\\\sd.csv'"
]
}
],
"source": [
Expand Down