|
20 | 20 | "cell_type": "markdown",
|
21 | 21 | "metadata": {},
|
22 | 22 | "source": [
|
23 |
| - "Ok, so now we have gotten a sense of how to take data from excel and move into a list in Python. We also learned about how to work with lists. In this lab we will practice reading from lists, adding elements to lists, and removing elements from lists." |
| 23 | + "Ok, so now that we have gotten a sense of how to read from a list and alter a list in Python, let's put this knowledge to practice. " |
24 | 24 | ]
|
25 | 25 | },
|
26 | 26 | {
|
|
43 | 43 | "cell_type": "markdown",
|
44 | 44 | "metadata": {},
|
45 | 45 | "source": [
|
46 |
| - "### Our data from a Google Sheet" |
| 46 | + "### Our initial data structure " |
47 | 47 | ]
|
48 | 48 | },
|
49 | 49 | {
|
50 | 50 | "cell_type": "markdown",
|
51 | 51 | "metadata": {},
|
52 | 52 | "source": [
|
53 |
| - "Once again, we will get our data from a Google Sheet, this time a sheet of [Travel Cities and Countries](https://docs.google.com/spreadsheets/d/1BTJMMFH9t4p5UmHj5kiC6PGfMN6yaaaZkocx0mDqTK0/edit#gid=0). " |
| 53 | + "In the previous lesson, we had a list of top travel cities." |
54 | 54 | ]
|
55 | 55 | },
|
56 | 56 | {
|
57 |
| - "cell_type": "markdown", |
58 |
| - "metadata": {}, |
59 |
| - "source": [ |
60 |
| - "" |
61 |
| - ] |
62 |
| - }, |
63 |
| - { |
64 |
| - "cell_type": "markdown", |
65 |
| - "metadata": {}, |
66 |
| - "source": [ |
67 |
| - "We already followed the steps of the previous lesson to download the spreadsheet and move it to the current folder. You can find the file [in the github repository](https://github.com/learn-co-curriculum/python-lists-lab)." |
68 |
| - ] |
69 |
| - }, |
70 |
| - { |
71 |
| - "cell_type": "markdown", |
72 |
| - "metadata": {}, |
| 57 | + "cell_type": "code", |
| 58 | + "execution_count": 2, |
| 59 | + "metadata": { |
| 60 | + "collapsed": true |
| 61 | + }, |
| 62 | + "outputs": [], |
73 | 63 | "source": [
|
74 |
| - "### From Local File to Python " |
| 64 | + "top_travel_cities = ['Solta', 'Greenville', 'Buenos Aires', 'Los Cabos', 'Walla Walla Valley', 'Marakesh', 'Albuquerque', 'Archipelago Sea', 'Iguazu Falls', 'Salina Island', 'Toronto', 'Pyeongchang']" |
75 | 65 | ]
|
76 | 66 | },
|
77 | 67 | {
|
78 | 68 | "cell_type": "markdown",
|
79 | 69 | "metadata": {},
|
80 | 70 | "source": [
|
81 |
| - "Now that we have this file in the folder we are working with, we can get this data into Python code." |
| 71 | + "In this lesson we can work with a list of each associated countries for each of those travel cities." |
82 | 72 | ]
|
83 | 73 | },
|
84 | 74 | {
|
85 | 75 | "cell_type": "code",
|
86 |
| - "execution_count": 3, |
| 76 | + "execution_count": 1, |
87 | 77 | "metadata": {},
|
88 | 78 | "outputs": [],
|
89 | 79 | "source": [
|
90 |
| - "import pandas\n", |
91 |
| - "file_name = './cities_and_countries.xlsx'\n", |
92 |
| - "travel_df = pandas.read_excel(file_name)\n", |
93 |
| - "travel_data = travel_df.to_dict('records')\n", |
94 |
| - "countries = list(map(lambda city: city['Country'] ,travel_data))" |
95 |
| - ] |
96 |
| - }, |
97 |
| - { |
98 |
| - "cell_type": "code", |
99 |
| - "execution_count": 4, |
100 |
| - "metadata": {}, |
101 |
| - "outputs": [ |
102 |
| - { |
103 |
| - "data": { |
104 |
| - "text/plain": [ |
105 |
| - "['Croatia',\n", |
106 |
| - " 'USA',\n", |
107 |
| - " 'Argentina',\n", |
108 |
| - " 'Mexico',\n", |
109 |
| - " 'USA',\n", |
110 |
| - " 'Morocco',\n", |
111 |
| - " 'New Mexico',\n", |
112 |
| - " 'Finland',\n", |
113 |
| - " 'Argentina',\n", |
114 |
| - " 'Italy',\n", |
115 |
| - " 'Canada',\n", |
116 |
| - " 'South Korea']" |
117 |
| - ] |
118 |
| - }, |
119 |
| - "execution_count": 4, |
120 |
| - "metadata": {}, |
121 |
| - "output_type": "execute_result" |
122 |
| - } |
123 |
| - ], |
124 |
| - "source": [ |
125 |
| - "countries" |
| 80 | + "countries = ['Croatia',\n", |
| 81 | + " 'USA',\n", |
| 82 | + " 'Argentina',\n", |
| 83 | + " 'Mexico',\n", |
| 84 | + " 'USA',\n", |
| 85 | + " 'Morocco',\n", |
| 86 | + " 'New Mexico',\n", |
| 87 | + " 'Finland',\n", |
| 88 | + " 'Argentina',\n", |
| 89 | + " 'Italy',\n", |
| 90 | + " 'Canada',\n", |
| 91 | + " 'South Korea']" |
126 | 92 | ]
|
127 | 93 | },
|
128 | 94 | {
|
|
149 | 115 | {
|
150 | 116 | "cell_type": "code",
|
151 | 117 | "execution_count": 10,
|
152 |
| - "metadata": {}, |
| 118 | + "metadata": { |
| 119 | + "collapsed": true |
| 120 | + }, |
153 | 121 | "outputs": [],
|
154 | 122 | "source": [
|
155 | 123 | "italy = countries[-3] # 'Italy'"
|
|
313 | 281 | {
|
314 | 282 | "cell_type": "code",
|
315 | 283 | "execution_count": 24,
|
316 |
| - "metadata": {}, |
| 284 | + "metadata": { |
| 285 | + "collapsed": true |
| 286 | + }, |
317 | 287 | "outputs": [],
|
318 | 288 | "source": [
|
319 | 289 | "countries[6] = 'USA'"
|
|
0 commit comments