Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffKatzy committed Mar 15, 2018
1 parent 3e089ee commit e2c9a6b
Showing 1 changed file with 19 additions and 66 deletions.
85 changes: 19 additions & 66 deletions index.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Now that we know a little bit about lists and dictionaries, we take data in a different digital format, and move it into code. This lesson is a little different as the goal is more to show what's possible with Python than to understand every line. But hopefully you can see that in just a few lines of code, you can use Python to work with data in other digital formats."
"Now that we know a little bit about lists and dictionaries, we take data in a different digital format, and move it into code. Hopefully, by the end of this lesson, you can see that in just a few lines of code, you can use Python to work with data in other digital formats."
]
},
{
Expand Down Expand Up @@ -50,7 +50,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"For example, here is [our list of travel cities and countries](https://docs.google.com/spreadsheets/d/1BTJMMFH9t4p5UmHj5kiC6PGfMN6yaaaZkocx0mDqTK0/edit?usp=drive_web&ouid=111878893823071965889) in the form of a google document."
"For example, here is [our list of travel cities and countries](https://docs.google.com/spreadsheets/d/1BTJMMFH9t4p5UmHj5kiC6PGfMN6yaaaZkocx0mDqTK0/edit?usp=drive_web&ouid=111878893823071965889) in the form of a google document. If you click on the link, you will see our spreadsheet."
]
},
{
Expand All @@ -64,7 +64,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Now if we download this list in the form of an .xlsx file we can start to work with it."
"Now if we download this spreadsheet in the form of an .xlsx file we can start to work with it."
]
},
{
Expand All @@ -78,7 +78,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"So we move the downloaded `.xlsx` file from our Downloads folder to our `lists-lab` folder so that we know how to access it. "
"Next, we move the downloaded `.xlsx` file from our Downloads folder to our `lists-lab` folder so that we can easily access it. "
]
},
{
Expand Down Expand Up @@ -106,7 +106,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
" And you can see that same file [in the github repository](https://github.com/learn-co-curriculum/python-lists-lab)."
" And you can see that same file [in the github repository](https://github.com/learn-co-curriculum/python-lists-lab), where the contents of this lab is also located."
]
},
{
Expand All @@ -127,39 +127,35 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"> ** Deep breath, soft eyes**: In the next gray box are four lines of code. They go over some topics we did not cover yet. So don't worry, this by the end of this unit you will understand all of this code. For right now, it's fine to just have a slight sense of what's going on. "
"> ** Deep breath, soft eyes**: In the gray box below are four lines of code. They go over some topics we did not cover yet. So don't worry, if you don't follow everything right now. By the end of this unit, you will understand all of the code. For right now, it's fine to just have a slight sense of what's going on. "
]
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'Area': 59, 'City': 'Solta', 'Country': 'Croatia', 'Population': 1700}"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"import pandas\n",
"travel_df = pandas.read_excel('./cities.xlsx')\n",
"cities = travel_df.to_dict('records')\n",
"cities[0]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"> Press shift+enter to run the code."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The code above relies on using an outside library called `pandas`, as it's good at reading excel files. A library is just a set of reusable functions. The `pandas` library is available for free online. We tell our current Jupyter notebook that we are about to use it with the line `import pandas`. \n",
"\n",
"And that gives us an object, like a dictionary, which has a method on it called `read_excel`. Similar so how we can call `{'foo': 'bar'}.keys()`. That's the benefit of a library, we can get methods that do not come out of the box with python. So we use the `read_excel` data to read our excel file, by providing the name of the file, `cities.xlsx`, and the preceding `./` just indicates that the file is found in the current folder. Finally with the line `travel_df.to_dict('records')` we return a list of our dictionaries representing our data. "
"And that gives us an object, like a dictionary, which has a method on it called `read_excel`. Similar so how we can call `{'foo': 'bar'}.keys()`. That's the benefit of a library, we can get methods that do not come out of the box with Python. So we use the `read_excel` data to read our excel file, by providing the name of the file, `cities.xlsx`, and the preceding `./` just indicates that the file is found in the current folder. Finally with the line `travel_df.to_dict('records')` we return a list of our dictionaries representing our data. You can see that when we access the first element of this list, we it returns our first dictionary. "
]
},
{
Expand All @@ -171,7 +167,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"metadata": {
"collapsed": true
},
Expand All @@ -188,52 +184,9 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[{'Area': 59, 'City': 'Solta', 'Country': 'Croatia', 'Population': 1700},\n",
" {'Area': 68, 'City': 'Greenville', 'Country': 'USA', 'Population': 84554},\n",
" {'Area': 4758,\n",
" 'City': 'Buenos Aires',\n",
" 'Country': 'Argentina',\n",
" 'Population': 13591863},\n",
" {'Area': 3750,\n",
" 'City': 'Los Cabos',\n",
" 'Country': 'Mexico',\n",
" 'Population': 287651},\n",
" {'Area': 33,\n",
" 'City': 'Walla Walla Valley',\n",
" 'Country': 'USA',\n",
" 'Population': 32237},\n",
" {'Area': 200, 'City': 'Marakesh', 'Country': 'Morocco', 'Population': 928850},\n",
" {'Area': 491,\n",
" 'City': 'Albuquerque',\n",
" 'Country': 'New Mexico',\n",
" 'Population': 559277},\n",
" {'Area': 8300,\n",
" 'City': 'Archipelago Sea',\n",
" 'Country': 'Finland',\n",
" 'Population': 60000},\n",
" {'Area': 672,\n",
" 'City': 'Iguazu Falls',\n",
" 'Country': 'Argentina',\n",
" 'Population': 0},\n",
" {'Area': 27, 'City': 'Salina Island', 'Country': 'Italy', 'Population': 4000},\n",
" {'Area': 2731571, 'City': 'Toronto', 'Country': 'Canada', 'Population': 630},\n",
" {'Area': 3194,\n",
" 'City': 'Pyeongchang',\n",
" 'Country': 'South Korea',\n",
" 'Population': 2581000}]"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"cities"
]
Expand Down

0 comments on commit e2c9a6b

Please sign in to comment.