"# Get everything starting with the second-last element\n",
"print(this_list[-2:])"
]
]
},
},
{
{
...
@@ -1056,24 +1062,7 @@
...
@@ -1056,24 +1062,7 @@
"cell_type": "markdown",
"cell_type": "markdown",
"metadata": {},
"metadata": {},
"source": [
"source": [
"This is an example of an [IPython magic command](https://ipython.readthedocs.io/en/stable/interactive/magics.html). These commands help with monitoring and managing your code environment.\n",
"This is an example of an [IPython magic command](https://ipython.readthedocs.io/en/stable/interactive/magics.html). These commands help with monitoring and managing your code environment.\n"
"\n",
"We should be aware of the variables that we create as they take memory and can bloat our environment.\n",
"\n",
"If we aren't using a variable anymore, it's not a bad idea to delete it. We can do so with `del`."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Remove the my_big_list_ variable\n",
"del my_big_list\n",
"\n",
"# my_big_list has left the building!\n",
"print(my_big_list)"
]
]
},
},
{
{
...
@@ -1098,7 +1087,7 @@
...
@@ -1098,7 +1087,7 @@
"source": [
"source": [
"## Lists and data analysis\n",
"## Lists and data analysis\n",
"\n",
"\n",
"Lists are a foundational variable type in Python. It's worth getting comfortable with them as a foundational variable type in Python.\n",
"Lists are a foundational variable type in Python. It's worth getting comfortable with them.\n",
"\n",
"\n",
"All that said, lists are not easily capable of handing many common data analysis tasks. Let's take doubling what we would call a \"range\" of cells, like we do in spreadsheets all the time:"
"All that said, lists are not easily capable of handing many common data analysis tasks. Let's take doubling what we would call a \"range\" of cells, like we do in spreadsheets all the time:"
]
]
...
@@ -1123,7 +1112,7 @@
...
@@ -1123,7 +1112,7 @@
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
"my_list = [1,9,5,3,8]\n",
"my_list = [1,9,5,3,8]\n",
"my_list * 2"
"my_list * 2"
]
]
},
},
...
@@ -1250,21 +1239,9 @@
...
@@ -1250,21 +1239,9 @@
"cell_type": "markdown",
"cell_type": "markdown",
"metadata": {},
"metadata": {},
"source": [
"source": [
"You will use packages all the time, and if you ever have an issue with one, a good place to start (after restarting the kernel!) is checking whether you have it installed, and what version.\n",
"_However_, when you are working with an Anaconda distribution of Python, it's better to download packages direcly from Anaconda: `!conda install [package name]`.\n",
"\n",
"\n",
"You can see all packages you've installed with `pip`, along with their versions, using `pip freeze`."
"To see what packages come installed with Anaconda, and what packages you can install from there, head to [Anaconda's documentation](https://docs.anaconda.com/anaconda/packages/py3.7_win-64/)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# This may take awhile\n",
"pip freeze"
]
]
},
},
{
{
...
@@ -1273,9 +1250,7 @@
...
@@ -1273,9 +1250,7 @@
"source": [
"source": [
"# Drill \n",
"# Drill \n",
"\n",
"\n",
"One interesting thing about packages is that they can be based on top of and borrow code from other packages!\n",
"Import the `seaborn` package. This is a visualization package that we'll use later in the class."
"\n",
"Import the `seaborn` package. This is a visualization package that we'll use later in the class, that is indeed built on top of another visualization package."