├── .ipynb_checkpoints ├── 1DayPython729-checkpoint.ipynb ├── 22JuneP101-checkpoint.ipynb ├── 22JunePart2-checkpoint.ipynb ├── 29June101Python-MoreofPandas-checkpoint.ipynb ├── 8_2_18_Python_1Day-checkpoint.ipynb ├── 8_5_18_PythonDay1-checkpoint.ipynb ├── EDAPythonC8-11_With_Womens Clothing E-Commerce Reviews-checkpoint.ipynb ├── July1PythonPart1-checkpoint.ipynb ├── July8PythonFD-checkpoint.ipynb ├── PandasPlay10June-checkpoint.ipynb ├── Part1-3June-checkpoint.ipynb ├── Part110JunePython-checkpoint.ipynb ├── Part1June17-checkpoint.ipynb ├── Part2Pandas-3-June-checkpoint.ipynb ├── PythonAdvancedJuly15-checkpoint.ipynb ├── PythonDataAnalytics729-checkpoint.ipynb ├── Regression-checkpoint.ipynb ├── Rplay-checkpoint.ipynb ├── Untitled-checkpoint.ipynb ├── Untitled1-checkpoint.ipynb ├── part2june10-checkpoint.ipynb ├── part2june17-checkpoint.ipynb ├── pricefromgooglefin-checkpoint.ipynb └── readinglogfiles-checkpoint.ipynb ├── 101_820.ipynb ├── 1DayPython729.ipynb ├── 8_2_18_Python_1Day.ipynb ├── 8_5_18_PythonDay1.ipynb ├── DownloadData.ipynb ├── EDAPythonC8-11_With_Womens Clothing E-Commerce Reviews.ipynb ├── July1PythonPart1.ipynb ├── July8PythonFD.ipynb ├── Learning Pandas.ipynb ├── PythonAdvancedJuly15.ipynb ├── PythonDataAnalytics729.ipynb ├── README.md ├── Regression.ipynb ├── Rplay.ipynb ├── Untitled.ipynb ├── Untitled1.ipynb ├── cleanedexce.p ├── cryptocorrelationPCA.ipynb ├── cryptory-google -trend.ipynb ├── data ├── Book2.csv ├── Book2.xlsx ├── Book3.csv ├── July8.xlsx ├── July8writtenbyPandas.xlsx ├── PandasPython.xlsx ├── Women.zip ├── Womens Clothing E-Commerce Reviews.csv ├── Womens Clothing E-Commerce Reviews.csv.zip ├── avgsal.csv ├── avgsal2.csv ├── df12.xlsx ├── macrodata.csv ├── myzip.zip └── salary.xlsx ├── dataJuly8.csv ├── df1pickle.p ├── dummydata - Sheet1.csv ├── dummydata - Sheet2.csv ├── ex15_sample.txt ├── joshi.p ├── june ├── 10june.csv ├── 22JuneP101.ipynb ├── 22JunePart2.ipynb ├── 29June101Python-MoreofPandas.ipynb ├── PandasPlay10June.ipynb ├── Part1-3June.ipynb ├── Part110JunePython.ipynb ├── Part1June17.ipynb ├── Part2Pandas-3-June.ipynb ├── pandas17june.csv ├── part2june10.ipynb └── part2june17.ipynb ├── nullplay.txt ├── pda ch3.ipynb ├── pda ch3.v2.ipynb ├── pda ch5.ipynb ├── pda san-ch4.ipynb ├── pricefromgooglefin.ipynb ├── rawdata.txt └── readinglogfiles.ipynb /.ipynb_checkpoints/1DayPython729-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": { 7 | "collapsed": true 8 | }, 9 | "outputs": [], 10 | "source": [] 11 | } 12 | ], 13 | "metadata": { 14 | "kernelspec": { 15 | "display_name": "Python 3.6", 16 | "language": "python", 17 | "name": "python36" 18 | }, 19 | "language_info": { 20 | "codemirror_mode": { 21 | "name": "ipython", 22 | "version": 3 23 | }, 24 | "file_extension": ".py", 25 | "mimetype": "text/x-python", 26 | "name": "python", 27 | "nbconvert_exporter": "python", 28 | "pygments_lexer": "ipython3", 29 | "version": "3.6.3" 30 | } 31 | }, 32 | "nbformat": 4, 33 | "nbformat_minor": 2 34 | } 35 | -------------------------------------------------------------------------------- /.ipynb_checkpoints/22JuneP101-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "data": { 10 | "text/plain": [ 11 | "10.0" 12 | ] 13 | }, 14 | "execution_count": 1, 15 | "metadata": {}, 16 | "output_type": "execute_result" 17 | } 18 | ], 19 | "source": [ 20 | "100/10" 21 | ] 22 | }, 23 | { 24 | "cell_type": "code", 25 | "execution_count": null, 26 | "metadata": {}, 27 | "outputs": [], 28 | "source": [] 29 | } 30 | ], 31 | "metadata": { 32 | "kernelspec": { 33 | "display_name": "Python 3.6", 34 | "language": "python", 35 | "name": "python36" 36 | }, 37 | "language_info": { 38 | "codemirror_mode": { 39 | "name": "ipython", 40 | "version": 3 41 | }, 42 | "file_extension": ".py", 43 | "mimetype": "text/x-python", 44 | "name": "python", 45 | "nbconvert_exporter": "python", 46 | "pygments_lexer": "ipython3", 47 | "version": "3.6.3" 48 | } 49 | }, 50 | "nbformat": 4, 51 | "nbformat_minor": 2 52 | } 53 | -------------------------------------------------------------------------------- /.ipynb_checkpoints/22JunePart2-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": { 7 | "collapsed": true 8 | }, 9 | "outputs": [], 10 | "source": [ 11 | "import pandas as pd\n", 12 | "\n", 13 | "pd.read_csv('book3.csv')" 14 | ] 15 | } 16 | ], 17 | "metadata": { 18 | "kernelspec": { 19 | "display_name": "Python 3.6", 20 | "language": "python", 21 | "name": "python36" 22 | }, 23 | "language_info": { 24 | "codemirror_mode": { 25 | "name": "ipython", 26 | "version": 3 27 | }, 28 | "file_extension": ".py", 29 | "mimetype": "text/x-python", 30 | "name": "python", 31 | "nbconvert_exporter": "python", 32 | "pygments_lexer": "ipython3", 33 | "version": "3.6.3" 34 | } 35 | }, 36 | "nbformat": 4, 37 | "nbformat_minor": 2 38 | } 39 | -------------------------------------------------------------------------------- /.ipynb_checkpoints/July8PythonFD-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stdout", 10 | "output_type": "stream", 11 | "text": [ 12 | "Hello World!\n", 13 | "Hello Again\n", 14 | "I like typing this.\n", 15 | "This is fun.\n", 16 | "Yay! Printing.\n", 17 | "I'd much rather you 'not'.\n", 18 | "I \"said\" do not touch this.\n" 19 | ] 20 | } 21 | ], 22 | "source": [ 23 | "print(\"Hello World!\")\n", 24 | "print(\"Hello Again\")\n", 25 | "print(\"I like typing this.\")\n", 26 | "print(\"This is fun.\")\n", 27 | "print('Yay! Printing.')\n", 28 | "print(\"I'd much rather you 'not'.\")\n", 29 | "print('I \"said\" do not touch this.')" 30 | ] 31 | }, 32 | { 33 | "cell_type": "code", 34 | "execution_count": null, 35 | "metadata": {}, 36 | "outputs": [], 37 | "source": [] 38 | } 39 | ], 40 | "metadata": { 41 | "kernelspec": { 42 | "display_name": "Python 3.6", 43 | "language": "python", 44 | "name": "python36" 45 | }, 46 | "language_info": { 47 | "codemirror_mode": { 48 | "name": "ipython", 49 | "version": 3 50 | }, 51 | "file_extension": ".py", 52 | "mimetype": "text/x-python", 53 | "name": "python", 54 | "nbconvert_exporter": "python", 55 | "pygments_lexer": "ipython3", 56 | "version": "3.6.3" 57 | } 58 | }, 59 | "nbformat": 4, 60 | "nbformat_minor": 2 61 | } 62 | -------------------------------------------------------------------------------- /.ipynb_checkpoints/PandasPlay10June-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": { 7 | "collapsed": true 8 | }, 9 | "outputs": [], 10 | "source": [] 11 | } 12 | ], 13 | "metadata": { 14 | "kernelspec": { 15 | "display_name": "Python 3.6", 16 | "language": "python", 17 | "name": "python36" 18 | }, 19 | "language_info": { 20 | "codemirror_mode": { 21 | "name": "ipython", 22 | "version": 3 23 | }, 24 | "file_extension": ".py", 25 | "mimetype": "text/x-python", 26 | "name": "python", 27 | "nbconvert_exporter": "python", 28 | "pygments_lexer": "ipython3", 29 | "version": "3.6.3" 30 | } 31 | }, 32 | "nbformat": 4, 33 | "nbformat_minor": 2 34 | } 35 | -------------------------------------------------------------------------------- /.ipynb_checkpoints/Part1-3June-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "x =1" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": 2, 15 | "metadata": {}, 16 | "outputs": [ 17 | { 18 | "data": { 19 | "text/plain": [ 20 | "1" 21 | ] 22 | }, 23 | "execution_count": 2, 24 | "metadata": {}, 25 | "output_type": "execute_result" 26 | } 27 | ], 28 | "source": [ 29 | "x" 30 | ] 31 | }, 32 | { 33 | "cell_type": "code", 34 | "execution_count": 3, 35 | "metadata": {}, 36 | "outputs": [ 37 | { 38 | "name": "stdout", 39 | "output_type": "stream", 40 | "text": [ 41 | "Hello World!\n", 42 | "Hello Again\n", 43 | "I like typing this.\n", 44 | "This is fun.\n", 45 | "Yay! Printing.\n", 46 | "I'd much rather you 'not'.\n", 47 | "I \"said\" do not touch this.\n" 48 | ] 49 | } 50 | ], 51 | "source": [ 52 | "print(\"Hello World!\")\n", 53 | "print(\"Hello Again\")\n", 54 | "print(\"I like typing this.\")\n", 55 | "print(\"This is fun.\")\n", 56 | "print('Yay! Printing.')\n", 57 | "print(\"I'd much rather you 'not'.\")\n", 58 | "print('I \"said\" do not touch this.')" 59 | ] 60 | }, 61 | { 62 | "cell_type": "markdown", 63 | "metadata": {}, 64 | "source": [ 65 | "This is markdown " 66 | ] 67 | }, 68 | { 69 | "cell_type": "code", 70 | "execution_count": 4, 71 | "metadata": {}, 72 | "outputs": [], 73 | "source": [ 74 | "# This is an old way to comment in Python code .. " 75 | ] 76 | }, 77 | { 78 | "cell_type": "code", 79 | "execution_count": 5, 80 | "metadata": {}, 81 | "outputs": [ 82 | { 83 | "name": "stdout", 84 | "output_type": "stream", 85 | "text": [ 86 | "I could have code like this.\n", 87 | "This will run.\n" 88 | ] 89 | } 90 | ], 91 | "source": [ 92 | "# A comment, this is so you can read your program later.\n", 93 | "# Anything after the # is ignored by pyhton.\n", 94 | "\n", 95 | "print(\"I could have code like this.\") # and the comment after is ignored\n", 96 | "\n", 97 | "# You can also use a comment to \"disable\" or comment out a piece of code:\n", 98 | "# print (\"This won't run.\")\n", 99 | "\n", 100 | "print(\"This will run.\")" 101 | ] 102 | }, 103 | { 104 | "cell_type": "code", 105 | "execution_count": 6, 106 | "metadata": {}, 107 | "outputs": [ 108 | { 109 | "name": "stdout", 110 | "output_type": "stream", 111 | "text": [ 112 | "I will now count my chickens:\n", 113 | "Hens 30.0\n", 114 | "Rosters 97\n", 115 | "Now I will count the eggs:\n", 116 | "7\n", 117 | "Is it true that 3 + 2 < 5 - 7?\n", 118 | "False\n", 119 | "What is 3 + 2? 5\n", 120 | "What is 5 - 7? -2\n", 121 | "Oh, that's why it's False.\n", 122 | "How about some more.\n", 123 | "It is greater? True\n", 124 | "It is greater or equal? True\n", 125 | "It is less or equal? False\n" 126 | ] 127 | } 128 | ], 129 | "source": [ 130 | "print(\"I will now count my chickens:\")\n", 131 | "\n", 132 | "print(\"Hens\", 25 + 30 / 6)\n", 133 | "print(\"Rosters\", 100 - 25 * 3 % 4)\n", 134 | "\n", 135 | "print(\"Now I will count the eggs:\")\n", 136 | "\n", 137 | "print(round(3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6))\n", 138 | "\n", 139 | "print(\"Is it true that 3 + 2 < 5 - 7?\")\n", 140 | "\n", 141 | "print(3 + 2 < 5 - 7)\n", 142 | "\n", 143 | "print(\"What is 3 + 2?\", 3 + 2)\n", 144 | "print(\"What is 5 - 7?\", 5 - 7)\n", 145 | "\n", 146 | "print(\"Oh, that's why it's False.\")\n", 147 | "\n", 148 | "print(\"How about some more.\")\n", 149 | "\n", 150 | "print(\"It is greater?\", 5 > -2)\n", 151 | "print(\"It is greater or equal?\", 5 >= -2)\n", 152 | "print(\"It is less or equal?\", 5 <= -2)" 153 | ] 154 | }, 155 | { 156 | "cell_type": "code", 157 | "execution_count": 7, 158 | "metadata": {}, 159 | "outputs": [ 160 | { 161 | "data": { 162 | "text/plain": [ 163 | "2" 164 | ] 165 | }, 166 | "execution_count": 7, 167 | "metadata": {}, 168 | "output_type": "execute_result" 169 | } 170 | ], 171 | "source": [ 172 | "1+1" 173 | ] 174 | }, 175 | { 176 | "cell_type": "code", 177 | "execution_count": 9, 178 | "metadata": {}, 179 | "outputs": [ 180 | { 181 | "name": "stdout", 182 | "output_type": "stream", 183 | "text": [ 184 | "5\n", 185 | "9\n" 186 | ] 187 | } 188 | ], 189 | "source": [ 190 | "x = 5\n", 191 | "y = 10\n", 192 | "\n", 193 | "print (x)\n", 194 | "x = y- 1\n", 195 | "print (x)" 196 | ] 197 | }, 198 | { 199 | "cell_type": "code", 200 | "execution_count": 10, 201 | "metadata": {}, 202 | "outputs": [ 203 | { 204 | "name": "stdout", 205 | "output_type": "stream", 206 | "text": [ 207 | "There are 100 cars available.\n", 208 | "There are only 30 drivers available.\n", 209 | "There will be 70 empty cars today\n", 210 | "We can transport 120.0 people today.\n", 211 | "We have 90 to carpool today.\n", 212 | "We need to put about 3.0 in each car.\n" 213 | ] 214 | } 215 | ], 216 | "source": [ 217 | "cars = 100\n", 218 | "space_in_a_car = 4.0\n", 219 | "drivers = 30\n", 220 | "passengers = 90\n", 221 | "cars_not_driven = cars - drivers\n", 222 | "cars_driven = drivers\n", 223 | "carpool_capacity = cars_driven * space_in_a_car\n", 224 | "average_passengers_per_car = passengers / cars_driven\n", 225 | "\n", 226 | "print(\"There are\", cars, \"cars available.\")\n", 227 | "print(\"There are only\", drivers, \"drivers available.\")\n", 228 | "print(\"There will be\", cars_not_driven, \"empty cars today\")\n", 229 | "print(\"We can transport\", carpool_capacity, \"people today.\")\n", 230 | "print(\"We have\", passengers, \"to carpool today.\")\n", 231 | "print(\"We need to put about\", average_passengers_per_car, \"in each car.\")" 232 | ] 233 | }, 234 | { 235 | "cell_type": "code", 236 | "execution_count": 13, 237 | "metadata": {}, 238 | "outputs": [ 239 | { 240 | "name": "stdout", 241 | "output_type": "stream", 242 | "text": [ 243 | "There are 100 cars available.\n" 244 | ] 245 | } 246 | ], 247 | "source": [ 248 | "print(\"There are \" + str(cars) + \" cars available.\")" 249 | ] 250 | }, 251 | { 252 | "cell_type": "code", 253 | "execution_count": 15, 254 | "metadata": {}, 255 | "outputs": [ 256 | { 257 | "name": "stdout", 258 | "output_type": "stream", 259 | "text": [ 260 | "Let's talk about Zed A. Shaw\n", 261 | "He's 74 inches tall.\n", 262 | "He's 180 pounds heavy.\n", 263 | "Actually that's not too heavy.\n", 264 | "He's got Blue eyes and Brown hair.\n", 265 | "His teeth are usually White depending on the coffee.\n", 266 | "If I add 35, 74, and 180 I get 289.\n" 267 | ] 268 | } 269 | ], 270 | "source": [ 271 | "my_name = 'Zed A. Shaw'\n", 272 | "my_age = 35 # not a lie\n", 273 | "my_height = 74 # inches\n", 274 | "my_weight = 180 # lbs\n", 275 | "my_eyes = 'Blue'\n", 276 | "my_teeth = 'White'\n", 277 | "my_hair = 'Brown'\n", 278 | "\n", 279 | "print(\"Let's talk about\", my_name)\n", 280 | "print(f\"He's {my_height} inches tall.\")\n", 281 | "print(f\"He's {my_weight} pounds heavy.\")\n", 282 | "print(\"Actually that's not too heavy.\")\n", 283 | "print(f\"He's got {my_eyes} eyes and {my_hair} hair.\")\n", 284 | "print(f\"His teeth are usually {my_teeth} depending on the coffee.\")\n", 285 | "\n", 286 | "# this line is tricky, try to get it exactly right\n", 287 | "total = my_age + my_height + my_weight\n", 288 | "print(f\"If I add {my_age}, {my_height}, and {my_weight} I get {total}.\")" 289 | ] 290 | }, 291 | { 292 | "cell_type": "code", 293 | "execution_count": 2, 294 | "metadata": {}, 295 | "outputs": [ 296 | { 297 | "name": "stdout", 298 | "output_type": "stream", 299 | "text": [ 300 | "You enter a dark room with two doors.\n", 301 | "Do you go through door #1 or door #2?\n", 302 | "> 1\n", 303 | "There's a giant bear here eating a cheese cake.\n", 304 | "What do you do?\n", 305 | "1. Take the cake.\n", 306 | "2. Scream at the bear.\n", 307 | "> 7\n", 308 | "Well, doing 7 is probably better.\n", 309 | "Bear runs away.\n" 310 | ] 311 | } 312 | ], 313 | "source": [ 314 | "print(\"You enter a dark room with two doors.\")\n", 315 | "print(\"Do you go through door #1 or door #2?\")\n", 316 | "\n", 317 | "door = input(\"> \")\n", 318 | "\n", 319 | "if door == \"1\":\n", 320 | " \n", 321 | " print(\"There's a giant bear here eating a cheese cake.\")\n", 322 | " print(\"What do you do?\")\n", 323 | " print(\"1. Take the cake.\")\n", 324 | " print(\"2. Scream at the bear.\")\n", 325 | "\n", 326 | " bear = input(\"> \")\n", 327 | "\n", 328 | " if bear == \"1\":\n", 329 | " print(\"The bear eats your face off. Good job!\")\n", 330 | " elif bear == \"2\":\n", 331 | " print(\"The bear eats your legs off. Good job!\")\n", 332 | " else:\n", 333 | " print(f\"Well, doing {bear} is probably better.\")\n", 334 | " print(\"Bear runs away.\")\n", 335 | "\n", 336 | "elif door == \"2\":\n", 337 | " print(\"You stare into the endless abyss at Cthulhu's retina.\")\n", 338 | " print(\"1. Blueberries.\")\n", 339 | " print(\"2. Yellow jacket clothespins.\")\n", 340 | " print(\"3. Understanding revolvers yelling melodies.\")\n", 341 | "\n", 342 | " insanity = input(\"> \")\n", 343 | "\n", 344 | " if insanity == \"1\" or insanity == \"2\":\n", 345 | " print(\"Your body survives powered by a mind of jello.\")\n", 346 | " print(\"Good job!\")\n", 347 | " else:\n", 348 | " print(\"The insanity rots your eyes into a pool of muck.\")\n", 349 | " print(\"Good job!\")\n", 350 | "\n", 351 | "else:\n", 352 | " print(\"You stumble around and fall on knife and die. Good job!\")" 353 | ] 354 | }, 355 | { 356 | "cell_type": "code", 357 | "execution_count": 3, 358 | "metadata": {}, 359 | "outputs": [], 360 | "source": [ 361 | "# What is today? If it is Sunday print you are right or else pring wrong\n" 362 | ] 363 | }, 364 | { 365 | "cell_type": "code", 366 | "execution_count": 8, 367 | "metadata": {}, 368 | "outputs": [ 369 | { 370 | "ename": "SyntaxError", 371 | "evalue": "invalid syntax (, line 7)", 372 | "output_type": "error", 373 | "traceback": [ 374 | "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m7\u001b[0m\n\u001b[0;31m else:\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n" 375 | ] 376 | } 377 | ], 378 | "source": [ 379 | "print(\"What day is today?\")\n", 380 | "day = input(\"> \")\n", 381 | "\n", 382 | "if day == \"Sunday\":\n", 383 | " print(\"Right.\")\n", 384 | "\n", 385 | "else:\n", 386 | " print(\"Wrong.\")\n", 387 | "\n", 388 | " " 389 | ] 390 | }, 391 | { 392 | "cell_type": "code", 393 | "execution_count": null, 394 | "metadata": {}, 395 | "outputs": [], 396 | "source": [] 397 | } 398 | ], 399 | "metadata": { 400 | "kernelspec": { 401 | "display_name": "Python 3.6", 402 | "language": "python", 403 | "name": "python36" 404 | }, 405 | "language_info": { 406 | "codemirror_mode": { 407 | "name": "ipython", 408 | "version": 3 409 | }, 410 | "file_extension": ".py", 411 | "mimetype": "text/x-python", 412 | "name": "python", 413 | "nbconvert_exporter": "python", 414 | "pygments_lexer": "ipython3", 415 | "version": "3.6.3" 416 | } 417 | }, 418 | "nbformat": 4, 419 | "nbformat_minor": 2 420 | } 421 | -------------------------------------------------------------------------------- /.ipynb_checkpoints/Part110JunePython-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stdout", 10 | "output_type": "stream", 11 | "text": [ 12 | "Hello World!\n", 13 | "Hello Again\n", 14 | "I like typing this.\n", 15 | "This is fun.\n", 16 | "Yay! Printing.\n", 17 | "I'd much rather you 'not'.\n", 18 | "I \"said\" do not touch this.\n" 19 | ] 20 | } 21 | ], 22 | "source": [ 23 | "print(\"Hello World!\")\n", 24 | "print(\"Hello Again\")\n", 25 | "print(\"I like typing this.\")\n", 26 | "print(\"This is fun.\")\n", 27 | "print('Yay! Printing.')\n", 28 | "print(\"I'd much rather you 'not'.\")\n", 29 | "print('I \"said\" do not touch this.')" 30 | ] 31 | }, 32 | { 33 | "cell_type": "code", 34 | "execution_count": null, 35 | "metadata": {}, 36 | "outputs": [], 37 | "source": [] 38 | } 39 | ], 40 | "metadata": { 41 | "kernelspec": { 42 | "display_name": "Python 3.6", 43 | "language": "python", 44 | "name": "python36" 45 | }, 46 | "language_info": { 47 | "codemirror_mode": { 48 | "name": "ipython", 49 | "version": 3 50 | }, 51 | "file_extension": ".py", 52 | "mimetype": "text/x-python", 53 | "name": "python", 54 | "nbconvert_exporter": "python", 55 | "pygments_lexer": "ipython3", 56 | "version": "3.6.3" 57 | } 58 | }, 59 | "nbformat": 4, 60 | "nbformat_minor": 2 61 | } 62 | -------------------------------------------------------------------------------- /.ipynb_checkpoints/Part1June17-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stdout", 10 | "output_type": "stream", 11 | "text": [ 12 | "Hello World!\n" 13 | ] 14 | } 15 | ], 16 | "source": [ 17 | "print(\"Hello World!\")" 18 | ] 19 | }, 20 | { 21 | "cell_type": "code", 22 | "execution_count": null, 23 | "metadata": {}, 24 | "outputs": [], 25 | "source": [] 26 | } 27 | ], 28 | "metadata": { 29 | "kernelspec": { 30 | "display_name": "Python 3.6", 31 | "language": "python", 32 | "name": "python36" 33 | }, 34 | "language_info": { 35 | "codemirror_mode": { 36 | "name": "ipython", 37 | "version": 3 38 | }, 39 | "file_extension": ".py", 40 | "mimetype": "text/x-python", 41 | "name": "python", 42 | "nbconvert_exporter": "python", 43 | "pygments_lexer": "ipython3", 44 | "version": "3.6.3" 45 | } 46 | }, 47 | "nbformat": 4, 48 | "nbformat_minor": 2 49 | } 50 | -------------------------------------------------------------------------------- /.ipynb_checkpoints/PythonDataAnalytics729-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": { 7 | "collapsed": true 8 | }, 9 | "outputs": [], 10 | "source": [ 11 | "import pandas as pd" 12 | ] 13 | } 14 | ], 15 | "metadata": { 16 | "kernelspec": { 17 | "display_name": "Python 3.6", 18 | "language": "python", 19 | "name": "python36" 20 | }, 21 | "language_info": { 22 | "codemirror_mode": { 23 | "name": "ipython", 24 | "version": 3 25 | }, 26 | "file_extension": ".py", 27 | "mimetype": "text/x-python", 28 | "name": "python", 29 | "nbconvert_exporter": "python", 30 | "pygments_lexer": "ipython3", 31 | "version": "3.6.3" 32 | } 33 | }, 34 | "nbformat": 4, 35 | "nbformat_minor": 2 36 | } 37 | -------------------------------------------------------------------------------- /.ipynb_checkpoints/Regression-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": { 7 | "collapsed": true 8 | }, 9 | "outputs": [], 10 | "source": [] 11 | } 12 | ], 13 | "metadata": { 14 | "kernelspec": { 15 | "display_name": "Python 3.6", 16 | "language": "python", 17 | "name": "python36" 18 | }, 19 | "language_info": { 20 | "codemirror_mode": { 21 | "name": "ipython", 22 | "version": 3 23 | }, 24 | "file_extension": ".py", 25 | "mimetype": "text/x-python", 26 | "name": "python", 27 | "nbconvert_exporter": "python", 28 | "pygments_lexer": "ipython3", 29 | "version": "3.6.3" 30 | } 31 | }, 32 | "nbformat": 4, 33 | "nbformat_minor": 2 34 | } 35 | -------------------------------------------------------------------------------- /.ipynb_checkpoints/Rplay-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 5, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stdout", 10 | "output_type": "stream", 11 | "text": [ 12 | "[1] \"The year is 4\"\n", 13 | "[1] \"The year is 5\"\n", 14 | "[1] \"The year is 6\"\n", 15 | "[1] \"The year is 7\"\n", 16 | "[1] \"The year is 8\"\n", 17 | "[1] \"The year is 9\"\n", 18 | "[1] \"The year is 10\"\n" 19 | ] 20 | } 21 | ], 22 | "source": [ 23 | "for (i in 4:10){\n", 24 | "\n", 25 | "print(paste(\"The year is\", i))\n", 26 | "}" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 6, 32 | "metadata": {}, 33 | "outputs": [], 34 | "source": [ 35 | "foo <- c(12, 22, 33)\n", 36 | "names(foo) <- c(\"tic\", \"tac\", \"toe\")" 37 | ] 38 | }, 39 | { 40 | "cell_type": "code", 41 | "execution_count": null, 42 | "metadata": {}, 43 | "outputs": [], 44 | "source": [] 45 | } 46 | ], 47 | "metadata": { 48 | "kernelspec": { 49 | "display_name": "R", 50 | "language": "R", 51 | "name": "r" 52 | }, 53 | "language_info": { 54 | "codemirror_mode": "r", 55 | "file_extension": ".r", 56 | "mimetype": "text/x-r-source", 57 | "name": "R", 58 | "pygments_lexer": "r", 59 | "version": "3.4.1" 60 | } 61 | }, 62 | "nbformat": 4, 63 | "nbformat_minor": 2 64 | } 65 | -------------------------------------------------------------------------------- /.ipynb_checkpoints/Untitled-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [], 3 | "metadata": {}, 4 | "nbformat": 4, 5 | "nbformat_minor": 2 6 | } 7 | -------------------------------------------------------------------------------- /.ipynb_checkpoints/Untitled1-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [], 3 | "metadata": {}, 4 | "nbformat": 4, 5 | "nbformat_minor": 2 6 | } 7 | -------------------------------------------------------------------------------- /.ipynb_checkpoints/part2june10-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stdout", 10 | "output_type": "stream", 11 | "text": [ 12 | "Too many cats! The world is doomed!\n", 13 | "The world is dry!\n", 14 | "People are greater than or equal to dogs.\n", 15 | "People are less than or equal to dogs.\n", 16 | "People are dogs.\n" 17 | ] 18 | } 19 | ], 20 | "source": [ 21 | "people = 20\n", 22 | "cats = 30\n", 23 | "dogs = 15\n", 24 | "\n", 25 | "if people < cats:\n", 26 | " print(\"Too many cats! The world is doomed!\")\n", 27 | "\n", 28 | "if people > cats:\n", 29 | " print(\"Not many cats! The world is saved!\")\n", 30 | "\n", 31 | "if people < dogs:\n", 32 | " print(\"The world is drooled on!\")\n", 33 | "\n", 34 | "if people > dogs:\n", 35 | " print(\"The world is dry!\")\n", 36 | "\n", 37 | "dogs += 5\n", 38 | "\n", 39 | "\n", 40 | "if people >= dogs:\n", 41 | " print(\"People are greater than or equal to dogs.\")\n", 42 | "\n", 43 | "if people <= dogs:\n", 44 | " print(\"People are less than or equal to dogs.\")\n", 45 | "\n", 46 | "if people == dogs:\n", 47 | " print(\"People are dogs.\")" 48 | ] 49 | }, 50 | { 51 | "cell_type": "code", 52 | "execution_count": null, 53 | "metadata": {}, 54 | "outputs": [], 55 | "source": [] 56 | } 57 | ], 58 | "metadata": { 59 | "kernelspec": { 60 | "display_name": "Python 3.6", 61 | "language": "python", 62 | "name": "python36" 63 | }, 64 | "language_info": { 65 | "codemirror_mode": { 66 | "name": "ipython", 67 | "version": 3 68 | }, 69 | "file_extension": ".py", 70 | "mimetype": "text/x-python", 71 | "name": "python", 72 | "nbconvert_exporter": "python", 73 | "pygments_lexer": "ipython3", 74 | "version": "3.6.3" 75 | } 76 | }, 77 | "nbformat": 4, 78 | "nbformat_minor": 2 79 | } 80 | -------------------------------------------------------------------------------- /.ipynb_checkpoints/part2june17-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": { 7 | "collapsed": true 8 | }, 9 | "outputs": [], 10 | "source": [] 11 | } 12 | ], 13 | "metadata": { 14 | "kernelspec": { 15 | "display_name": "Python 3.6", 16 | "language": "python", 17 | "name": "python36" 18 | }, 19 | "language_info": { 20 | "codemirror_mode": { 21 | "name": "ipython", 22 | "version": 3 23 | }, 24 | "file_extension": ".py", 25 | "mimetype": "text/x-python", 26 | "name": "python", 27 | "nbconvert_exporter": "python", 28 | "pygments_lexer": "ipython3", 29 | "version": "3.6.3" 30 | } 31 | }, 32 | "nbformat": 4, 33 | "nbformat_minor": 2 34 | } 35 | -------------------------------------------------------------------------------- /.ipynb_checkpoints/pricefromgooglefin-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "ename": "ModuleNotFoundError", 10 | "evalue": "No module named 'pandas_datareader'", 11 | "output_type": "error", 12 | "traceback": [ 13 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", 14 | "\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", 15 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mpandas_datareader\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mfix_yahoo_finance\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0myf\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0myf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpdr_override\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0msymbol\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m'AMZN'\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", 16 | "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'pandas_datareader'" 17 | ] 18 | } 19 | ], 20 | "source": [ 21 | "from pandas_datareader import data\n", 22 | "import fix_yahoo_finance as yf\n", 23 | "yf.pdr_override() \n", 24 | "\n", 25 | "symbol = 'AMZN'\n", 26 | "data_source='google'\n", 27 | "start_date = '2010-01-01'\n", 28 | "end_date = '2016-01-01'\n", 29 | "df = data.get_data_yahoo(symbol, start_date, end_date)\n", 30 | "\n", 31 | "df.head()" 32 | ] 33 | }, 34 | { 35 | "cell_type": "code", 36 | "execution_count": null, 37 | "metadata": {}, 38 | "outputs": [], 39 | "source": [] 40 | } 41 | ], 42 | "metadata": { 43 | "kernelspec": { 44 | "display_name": "Python 3.6", 45 | "language": "python", 46 | "name": "python36" 47 | }, 48 | "language_info": { 49 | "codemirror_mode": { 50 | "name": "ipython", 51 | "version": 3 52 | }, 53 | "file_extension": ".py", 54 | "mimetype": "text/x-python", 55 | "name": "python", 56 | "nbconvert_exporter": "python", 57 | "pygments_lexer": "ipython3", 58 | "version": "3.6.3" 59 | } 60 | }, 61 | "nbformat": 4, 62 | "nbformat_minor": 2 63 | } 64 | -------------------------------------------------------------------------------- /.ipynb_checkpoints/readinglogfiles-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "data": { 10 | "text/plain": [ 11 | "['x', 'y', 'z']" 12 | ] 13 | }, 14 | "execution_count": 1, 15 | "metadata": {}, 16 | "output_type": "execute_result" 17 | } 18 | ], 19 | "source": [ 20 | "x=\"\"\"x\n", 21 | "\n", 22 | "y\n", 23 | "\n", 24 | "z\"\"\"\n", 25 | "#x.count('\\n\\n')\n", 26 | "x.split('\\n\\n')" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": null, 32 | "metadata": {}, 33 | "outputs": [], 34 | "source": [ 35 | "# reading from rawdata.txt" 36 | ] 37 | }, 38 | { 39 | "cell_type": "code", 40 | "execution_count": null, 41 | "metadata": {}, 42 | "outputs": [], 43 | "source": [] 44 | }, 45 | { 46 | "cell_type": "code", 47 | "execution_count": 23, 48 | "metadata": {}, 49 | "outputs": [], 50 | "source": [ 51 | "with open('rawdata.txt', 'r') as myfile:\n", 52 | " data = myfile.read()" 53 | ] 54 | }, 55 | { 56 | "cell_type": "code", 57 | "execution_count": 28, 58 | "metadata": {}, 59 | "outputs": [ 60 | { 61 | "data": { 62 | "text/plain": [ 63 | "'hi this is first entry - col1\\ni am 2nd line of first entry -col\\n\\nthis is second - co1\\ni am 2nd line of 2nd entyr -co2\\n\\nthis is third - col1\\ni am thir line of new tnryt - col2'" 64 | ] 65 | }, 66 | "execution_count": 28, 67 | "metadata": {}, 68 | "output_type": "execute_result" 69 | } 70 | ], 71 | "source": [ 72 | "data" 73 | ] 74 | }, 75 | { 76 | "cell_type": "code", 77 | "execution_count": 29, 78 | "metadata": {}, 79 | "outputs": [], 80 | "source": [ 81 | "mylist= data.split('\\n\\n')" 82 | ] 83 | }, 84 | { 85 | "cell_type": "code", 86 | "execution_count": 30, 87 | "metadata": {}, 88 | "outputs": [ 89 | { 90 | "data": { 91 | "text/plain": [ 92 | "['hi this is first entry - col1\\ni am 2nd line of first entry -col',\n", 93 | " 'this is second - co1\\ni am 2nd line of 2nd entyr -co2',\n", 94 | " 'this is third - col1\\ni am thir line of new tnryt - col2']" 95 | ] 96 | }, 97 | "execution_count": 30, 98 | "metadata": {}, 99 | "output_type": "execute_result" 100 | } 101 | ], 102 | "source": [ 103 | "mylist" 104 | ] 105 | }, 106 | { 107 | "cell_type": "code", 108 | "execution_count": 31, 109 | "metadata": {}, 110 | "outputs": [ 111 | { 112 | "data": { 113 | "text/plain": [ 114 | "['hi this is first entry - col1', 'i am 2nd line of first entry -col']" 115 | ] 116 | }, 117 | "execution_count": 31, 118 | "metadata": {}, 119 | "output_type": "execute_result" 120 | } 121 | ], 122 | "source": [ 123 | "mylist[0].split('\\n')" 124 | ] 125 | }, 126 | { 127 | "cell_type": "code", 128 | "execution_count": 34, 129 | "metadata": {}, 130 | "outputs": [ 131 | { 132 | "name": "stdout", 133 | "output_type": "stream", 134 | "text": [ 135 | "['hi this is first entry - col1', 'i am 2nd line of first entry -col']\n", 136 | "['this is second - co1', 'i am 2nd line of 2nd entyr -co2']\n", 137 | "['this is third - col1', 'i am thir line of new tnryt - col2']\n" 138 | ] 139 | } 140 | ], 141 | "source": [ 142 | "collist =[]\n", 143 | "for x in mylist:\n", 144 | " #mylist.append(x.split('\\n\\n'))\n", 145 | " print (x.split('\\n'))\n", 146 | " collist.append(x.split('\\n'))\n" 147 | ] 148 | }, 149 | { 150 | "cell_type": "code", 151 | "execution_count": 35, 152 | "metadata": {}, 153 | "outputs": [ 154 | { 155 | "data": { 156 | "text/plain": [ 157 | "[['hi this is first entry - col1', 'i am 2nd line of first entry -col'],\n", 158 | " ['this is second - co1', 'i am 2nd line of 2nd entyr -co2'],\n", 159 | " ['this is third - col1', 'i am thir line of new tnryt - col2']]" 160 | ] 161 | }, 162 | "execution_count": 35, 163 | "metadata": {}, 164 | "output_type": "execute_result" 165 | } 166 | ], 167 | "source": [ 168 | "collist" 169 | ] 170 | }, 171 | { 172 | "cell_type": "code", 173 | "execution_count": 37, 174 | "metadata": {}, 175 | "outputs": [ 176 | { 177 | "ename": "NameError", 178 | "evalue": "name 'pd' is not defined", 179 | "output_type": "error", 180 | "traceback": [ 181 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", 182 | "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", 183 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mtable\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcollist\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mdf\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mpd\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mDataFrame\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtable\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0mdf\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtranspose\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\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[0mcolumns\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m'Heading1'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'Heading2'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mdf\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", 184 | "\u001b[0;31mNameError\u001b[0m: name 'pd' is not defined" 185 | ] 186 | } 187 | ], 188 | "source": [ 189 | "table = collist\n", 190 | "df = pd.DataFrame(table)\n", 191 | "df = df.transpose()\n", 192 | "df.columns = ['Heading1', 'Heading2']\n", 193 | "df" 194 | ] 195 | }, 196 | { 197 | "cell_type": "code", 198 | "execution_count": null, 199 | "metadata": {}, 200 | "outputs": [], 201 | "source": [] 202 | } 203 | ], 204 | "metadata": { 205 | "kernelspec": { 206 | "display_name": "Python 3.6", 207 | "language": "python", 208 | "name": "python36" 209 | }, 210 | "language_info": { 211 | "codemirror_mode": { 212 | "name": "ipython", 213 | "version": 3 214 | }, 215 | "file_extension": ".py", 216 | "mimetype": "text/x-python", 217 | "name": "python", 218 | "nbconvert_exporter": "python", 219 | "pygments_lexer": "ipython3", 220 | "version": "3.6.3" 221 | } 222 | }, 223 | "nbformat": 4, 224 | "nbformat_minor": 2 225 | } 226 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Python Data Science Bootcamp NYC Affordable Cost-Effective Best Weekend Classes 2 | 3 | Python SQL 101 Class Bootcamp Big Data Sciene Tutor NYC, New York 4 | 5 | Developed various passive course for bootcamps in Data Analytics, took classes at USA (New York) and India. Training theme centered around projects, for example, your portfolio or even themes you are doing at work in Manhattan, New York City. Very different from the repetitive courses given by other tutors with a fixed syllabus. The outcome of such engagement is a product you can use. And am focused to build your github portfolio. Also worked at New York Python SQL Bootcamp Coding Classes (Affordable & Cost-effective Machine Learning). Running the Best Free classes in NYC / India. Experience in creating and delivered for difference bootcamp: SQL 101 & Python 101 Classes, Big Data Science Classes for beginners in Analytics & Data Science, Weekend part time full time classes in Manhattan & Queens, 1 on 1 Tutoring, Free weekend 2hrs class, New York Python SQL Bootcamp for Non Programmers (Affordable Machine Learning). 6 | 7 | You can attend my meetup, classes in Mahattan or NYC. 8 | 9 | PPT for Python 1 Day bootcamp in NYC New York 10 | https://docs.google.com/presentation/d/1LmBC6uq2iZPDSnqjdaZqILkDJjl4SB-97ARgPFEejHE/edit?usp=sharing 11 | 12 | PPT for Data Science / Machine Learning 101 in NYC New York 13 | https://docs.google.com/presentation/d/1HrmkW6d53I6YETWS5pDDhE6E3OXTlDljcHyjARLdLIE/edit?usp=sharing 14 | 15 | Ginger Beer and Free Python support class in NYC New York - Manhattan Upper East 16 | https://docs.google.com/presentation/d/1Oz8P88XttY6Z2RA7Wz7ZFfVwgvMGR7hPziZ4Pm2PfFI/edit?usp=sharing 17 | 18 | http://learnprogrammingnyc.com/ 19 | 20 | https://www.eventbrite.com/o/python-sql-data-science-class-bootcamp-nyc-affordable-coding-programming-14448368531 21 | 22 | https://notebooks.azure.com/shivgan3/libraries/PythonClassesNYCBootcamp 23 | 24 | http://learnpythondatasciencenyc.site/ 25 | 26 | http://bigdatascienceblockchainnyc.site/ 27 | 28 | http://excelhelponsiteconsultantnyc.site 29 | 30 | http://ebscorp.us/ 31 | 32 | 33 | Contact: 34 | Shivgan Joshi 35 | 929 356 5046 36 | www.qcfinance.in 37 | -------------------------------------------------------------------------------- /Rplay.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 5, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stdout", 10 | "output_type": "stream", 11 | "text": [ 12 | "[1] \"The year is 4\"\n", 13 | "[1] \"The year is 5\"\n", 14 | "[1] \"The year is 6\"\n", 15 | "[1] \"The year is 7\"\n", 16 | "[1] \"The year is 8\"\n", 17 | "[1] \"The year is 9\"\n", 18 | "[1] \"The year is 10\"\n" 19 | ] 20 | } 21 | ], 22 | "source": [ 23 | "for (i in 4:10){\n", 24 | "\n", 25 | "print(paste(\"The year is\", i))\n", 26 | "}" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 6, 32 | "metadata": {}, 33 | "outputs": [], 34 | "source": [ 35 | "foo <- c(12, 22, 33)\n", 36 | "names(foo) <- c(\"tic\", \"tac\", \"toe\")" 37 | ] 38 | }, 39 | { 40 | "cell_type": "code", 41 | "execution_count": null, 42 | "metadata": {}, 43 | "outputs": [], 44 | "source": [] 45 | } 46 | ], 47 | "metadata": { 48 | "kernelspec": { 49 | "display_name": "R", 50 | "language": "R", 51 | "name": "r" 52 | }, 53 | "language_info": { 54 | "codemirror_mode": "r", 55 | "file_extension": ".r", 56 | "mimetype": "text/x-r-source", 57 | "name": "R", 58 | "pygments_lexer": "r", 59 | "version": "3.4.1" 60 | } 61 | }, 62 | "nbformat": 4, 63 | "nbformat_minor": 2 64 | } 65 | -------------------------------------------------------------------------------- /Untitled.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [], 3 | "metadata": {}, 4 | "nbformat": 4, 5 | "nbformat_minor": 2 6 | } 7 | -------------------------------------------------------------------------------- /Untitled1.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "fahrenheit_to_kelvin <- function(temp_F) {\n", 10 | "temp_K <- ((temp_F - 32) * (5 / 9)) + 273.15\n", 11 | " return(temp_K)\n", 12 | "}" 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": 2, 18 | "metadata": {}, 19 | "outputs": [ 20 | { 21 | "data": { 22 | "text/html": [ 23 | "310.927777777778" 24 | ], 25 | "text/latex": [ 26 | "310.927777777778" 27 | ], 28 | "text/markdown": [ 29 | "310.927777777778" 30 | ], 31 | "text/plain": [ 32 | "[1] 310.9278" 33 | ] 34 | }, 35 | "metadata": {}, 36 | "output_type": "display_data" 37 | } 38 | ], 39 | "source": [ 40 | "fahrenheit_to_kelvin(100)" 41 | ] 42 | }, 43 | { 44 | "cell_type": "markdown", 45 | "metadata": {}, 46 | "source": [ 47 | "def fahrenheit_to_kelvin(temp_F): \n", 48 | " temp_K <- ((temp_F - 32) * (5 / 9)) + 273.15\n", 49 | " return(temp_K)\n" 50 | ] 51 | } 52 | ], 53 | "metadata": { 54 | "kernelspec": { 55 | "display_name": "R", 56 | "language": "R", 57 | "name": "r" 58 | }, 59 | "language_info": { 60 | "codemirror_mode": "r", 61 | "file_extension": ".r", 62 | "mimetype": "text/x-r-source", 63 | "name": "R", 64 | "pygments_lexer": "r", 65 | "version": "3.4.1" 66 | } 67 | }, 68 | "nbformat": 4, 69 | "nbformat_minor": 2 70 | } 71 | -------------------------------------------------------------------------------- /cleanedexce.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Python-Big-Data-Science-NYC/PythonDataScienceBootcampNYC/4bae79d5cc9fe4268dd4f4ac8e3acfeaf8ad8634/cleanedexce.p -------------------------------------------------------------------------------- /data/Book2.csv: -------------------------------------------------------------------------------- 1 | Name,Agbe,City 2 | A,24,Queens 3 | B,34,Manhattan 4 | C,30,Queens 5 | D,34,Manhattan 6 | E,34,Manhattan 7 | F,20,Manhattan 8 | -------------------------------------------------------------------------------- /data/Book2.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Python-Big-Data-Science-NYC/PythonDataScienceBootcampNYC/4bae79d5cc9fe4268dd4f4ac8e3acfeaf8ad8634/data/Book2.xlsx -------------------------------------------------------------------------------- /data/Book3.csv: -------------------------------------------------------------------------------- 1 | Name,Agbe,City 2 | A,24,Queens 3 | B,34,Manhattan 4 | C,30,Queens 5 | D,34,Manhattan 6 | E,34,Manhattan 7 | F,20,Manhattan 8 | -------------------------------------------------------------------------------- /data/July8.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Python-Big-Data-Science-NYC/PythonDataScienceBootcampNYC/4bae79d5cc9fe4268dd4f4ac8e3acfeaf8ad8634/data/July8.xlsx -------------------------------------------------------------------------------- /data/July8writtenbyPandas.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Python-Big-Data-Science-NYC/PythonDataScienceBootcampNYC/4bae79d5cc9fe4268dd4f4ac8e3acfeaf8ad8634/data/July8writtenbyPandas.xlsx -------------------------------------------------------------------------------- /data/PandasPython.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Python-Big-Data-Science-NYC/PythonDataScienceBootcampNYC/4bae79d5cc9fe4268dd4f4ac8e3acfeaf8ad8634/data/PandasPython.xlsx -------------------------------------------------------------------------------- /data/Women.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Python-Big-Data-Science-NYC/PythonDataScienceBootcampNYC/4bae79d5cc9fe4268dd4f4ac8e3acfeaf8ad8634/data/Women.zip -------------------------------------------------------------------------------- /data/Womens Clothing E-Commerce Reviews.csv.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Python-Big-Data-Science-NYC/PythonDataScienceBootcampNYC/4bae79d5cc9fe4268dd4f4ac8e3acfeaf8ad8634/data/Womens Clothing E-Commerce Reviews.csv.zip -------------------------------------------------------------------------------- /data/avgsal.csv: -------------------------------------------------------------------------------- 1 | City,Avg Salary 2 | M,15000 3 | B,17000 4 | Q,10000 -------------------------------------------------------------------------------- /data/avgsal2.csv: -------------------------------------------------------------------------------- 1 | City,Avg Salary 2 | M,15000 3 | B,17000 4 | -------------------------------------------------------------------------------- /data/df12.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Python-Big-Data-Science-NYC/PythonDataScienceBootcampNYC/4bae79d5cc9fe4268dd4f4ac8e3acfeaf8ad8634/data/df12.xlsx -------------------------------------------------------------------------------- /data/macrodata.csv: -------------------------------------------------------------------------------- 1 | year,quarter,realgdp,realcons,realinv,realgovt,realdpi,cpi,m1,tbilrate,unemp,pop,infl,realint 2 | 1959.0,1.0,2710.349,1707.4,286.898,470.045,1886.9,28.98,139.7,2.82,5.8,177.146,0.0,0.0 3 | 1959.0,2.0,2778.801,1733.7,310.859,481.301,1919.7,29.15,141.7,3.08,5.1,177.83,2.34,0.74 4 | 1959.0,3.0,2775.488,1751.8,289.226,491.26,1916.4,29.35,140.5,3.82,5.3,178.657,2.74,1.09 5 | 1959.0,4.0,2785.204,1753.7,299.356,484.052,1931.3,29.37,140.0,4.33,5.6,179.386,0.27,4.06 6 | 1960.0,1.0,2847.699,1770.5,331.722,462.199,1955.5,29.54,139.6,3.5,5.2,180.007,2.31,1.19 7 | 1960.0,2.0,2834.39,1792.9,298.152,460.4,1966.1,29.55,140.2,2.68,5.2,180.671,0.14,2.55 8 | 1960.0,3.0,2839.022,1785.8,296.375,474.676,1967.8,29.75,140.9,2.36,5.6,181.528,2.7,-0.34 9 | 1960.0,4.0,2802.616,1788.2,259.764,476.434,1966.6,29.84,141.1,2.29,6.3,182.287,1.21,1.08 10 | 1961.0,1.0,2819.264,1787.7,266.405,475.854,1984.5,29.81,142.1,2.37,6.8,182.992,-0.4,2.77 11 | 1961.0,2.0,2872.005,1814.3,286.246,480.328,2014.4,29.92,142.9,2.29,7.0,183.691,1.47,0.81 12 | 1961.0,3.0,2918.419,1823.1,310.227,493.828,2041.9,29.98,144.1,2.32,6.8,184.524,0.8,1.52 13 | 1961.0,4.0,2977.83,1859.6,315.463,502.521,2082.0,30.04,145.2,2.6,6.2,185.242,0.8,1.8 14 | 1962.0,1.0,3031.241,1879.4,334.271,520.96,2101.7,30.21,146.4,2.73,5.6,185.874,2.26,0.47 15 | 1962.0,2.0,3064.709,1902.5,331.039,523.066,2125.2,30.22,146.5,2.78,5.5,186.538,0.13,2.65 16 | 1962.0,3.0,3093.047,1917.9,336.962,538.838,2137.0,30.38,146.7,2.78,5.6,187.323,2.11,0.67 17 | 1962.0,4.0,3100.563,1945.1,325.65,535.912,2154.6,30.44,148.3,2.87,5.5,188.013,0.79,2.08 18 | 1963.0,1.0,3141.087,1958.2,343.721,522.917,2172.5,30.48,149.7,2.9,5.8,188.58,0.53,2.38 19 | 1963.0,2.0,3180.447,1976.9,348.73,518.108,2193.1,30.69,151.3,3.03,5.7,189.242,2.75,0.29 20 | 1963.0,3.0,3240.332,2003.8,360.102,546.893,2217.9,30.75,152.6,3.38,5.5,190.028,0.78,2.6 21 | 1963.0,4.0,3264.967,2020.6,364.534,532.383,2254.6,30.94,153.7,3.52,5.6,190.668,2.46,1.06 22 | 1964.0,1.0,3338.246,2060.5,379.523,529.686,2299.6,30.95,154.8,3.51,5.5,191.245,0.13,3.38 23 | 1964.0,2.0,3376.587,2096.7,377.778,526.175,2362.1,31.02,156.8,3.47,5.2,191.889,0.9,2.57 24 | 1964.0,3.0,3422.469,2135.2,386.754,522.008,2392.7,31.12,159.2,3.53,5.0,192.631,1.29,2.25 25 | 1964.0,4.0,3431.957,2141.2,389.91,514.603,2420.4,31.28,160.7,3.76,5.0,193.223,2.05,1.71 26 | 1965.0,1.0,3516.251,2188.8,429.145,508.006,2447.4,31.38,162.0,3.93,4.9,193.709,1.28,2.65 27 | 1965.0,2.0,3563.96,2213.0,429.119,508.931,2474.5,31.58,163.1,3.84,4.7,194.303,2.54,1.3 28 | 1965.0,3.0,3636.285,2251.0,444.444,529.446,2542.6,31.65,166.0,3.93,4.4,194.997,0.89,3.04 29 | 1965.0,4.0,3724.014,2314.3,446.493,544.121,2594.1,31.88,169.1,4.35,4.1,195.539,2.9,1.46 30 | 1966.0,1.0,3815.423,2348.5,484.244,556.593,2618.4,32.28,171.8,4.62,3.9,195.999,4.99,-0.37 31 | 1966.0,2.0,3828.124,2354.5,475.408,571.371,2624.7,32.45,170.3,4.65,3.8,196.56,2.1,2.55 32 | 1966.0,3.0,3853.301,2381.5,470.697,594.514,2657.8,32.85,171.2,5.23,3.8,197.207,4.9,0.33 33 | 1966.0,4.0,3884.52,2391.4,472.957,599.528,2688.2,32.9,171.9,5.0,3.7,197.736,0.61,4.39 34 | 1967.0,1.0,3918.74,2405.3,460.007,640.682,2728.4,33.1,174.2,4.22,3.8,198.206,2.42,1.8 35 | 1967.0,2.0,3919.556,2438.1,440.393,631.43,2750.8,33.4,178.1,3.78,3.8,198.712,3.61,0.17 36 | 1967.0,3.0,3950.826,2450.6,453.033,641.504,2777.1,33.7,181.6,4.42,3.8,199.311,3.58,0.84 37 | 1967.0,4.0,3980.97,2465.7,462.834,640.234,2797.4,34.1,184.3,4.9,3.9,199.808,4.72,0.18 38 | 1968.0,1.0,4063.013,2524.6,472.907,651.378,2846.2,34.4,186.6,5.18,3.7,200.208,3.5,1.67 39 | 1968.0,2.0,4131.998,2563.3,492.026,646.145,2893.5,34.9,190.5,5.5,3.5,200.706,5.77,-0.28 40 | 1968.0,3.0,4160.267,2611.5,476.053,640.615,2899.3,35.3,194.0,5.21,3.5,201.29,4.56,0.65 41 | 1968.0,4.0,4178.293,2623.5,480.998,636.729,2918.4,35.7,198.7,5.85,3.4,201.76,4.51,1.34 42 | 1969.0,1.0,4244.1,2652.9,512.686,633.224,2923.4,36.3,200.7,6.08,3.4,202.161,6.67,-0.58 43 | 1969.0,2.0,4256.46,2669.8,508.601,623.16,2952.9,36.8,201.7,6.49,3.4,202.677,5.47,1.02 44 | 1969.0,3.0,4283.378,2682.7,520.36,623.613,3012.9,37.3,202.9,7.02,3.6,203.302,5.4,1.63 45 | 1969.0,4.0,4263.261,2704.1,492.334,606.9,3034.9,37.9,206.2,7.64,3.6,203.849,6.38,1.26 46 | 1970.0,1.0,4256.573,2720.7,476.925,594.888,3050.1,38.5,206.7,6.76,4.2,204.401,6.28,0.47 47 | 1970.0,2.0,4264.289,2733.2,478.419,576.257,3103.5,38.9,208.0,6.66,4.8,205.052,4.13,2.52 48 | 1970.0,3.0,4302.259,2757.1,486.594,567.743,3145.4,39.4,212.9,6.15,5.2,205.788,5.11,1.04 49 | 1970.0,4.0,4256.637,2749.6,458.406,564.666,3135.1,39.9,215.5,4.86,5.8,206.466,5.04,-0.18 50 | 1971.0,1.0,4374.016,2802.2,517.935,542.709,3197.3,40.1,220.0,3.65,5.9,207.065,2.0,1.65 51 | 1971.0,2.0,4398.829,2827.9,533.986,534.905,3245.3,40.6,224.9,4.76,5.9,207.661,4.96,-0.19 52 | 1971.0,3.0,4433.943,2850.4,541.01,532.646,3259.7,40.9,227.2,4.7,6.0,208.345,2.94,1.75 53 | 1971.0,4.0,4446.264,2897.8,524.085,516.14,3294.2,41.2,230.1,3.87,6.0,208.917,2.92,0.95 54 | 1972.0,1.0,4525.769,2936.5,561.147,518.192,3314.9,41.5,235.6,3.55,5.8,209.386,2.9,0.64 55 | 1972.0,2.0,4633.101,2992.6,595.495,526.473,3346.1,41.8,238.8,3.86,5.7,209.896,2.88,0.98 56 | 1972.0,3.0,4677.503,3038.8,603.97,498.116,3414.6,42.2,245.0,4.47,5.6,210.479,3.81,0.66 57 | 1972.0,4.0,4754.546,3110.1,607.104,496.54,3550.5,42.7,251.5,5.09,5.3,210.985,4.71,0.38 58 | 1973.0,1.0,4876.166,3167.0,645.654,504.838,3590.7,43.7,252.7,5.98,5.0,211.42,9.26,-3.28 59 | 1973.0,2.0,4932.571,3165.4,675.837,497.033,3626.2,44.2,257.5,7.19,4.9,211.909,4.55,2.64 60 | 1973.0,3.0,4906.252,3176.7,649.412,475.897,3644.4,45.6,259.0,8.06,4.8,212.475,12.47,-4.41 61 | 1973.0,4.0,4953.05,3167.4,674.253,476.174,3688.9,46.8,263.8,7.68,4.8,212.932,10.39,-2.71 62 | 1974.0,1.0,4909.617,3139.7,631.23,491.043,3632.3,48.1,267.2,7.8,5.1,213.361,10.96,-3.16 63 | 1974.0,2.0,4922.188,3150.6,628.102,490.177,3601.1,49.3,269.3,7.89,5.2,213.854,9.86,-1.96 64 | 1974.0,3.0,4873.52,3163.6,592.672,492.586,3612.4,51.0,272.3,8.16,5.6,214.451,13.56,-5.4 65 | 1974.0,4.0,4854.34,3117.3,598.306,496.176,3596.0,52.3,273.9,6.96,6.6,214.931,10.07,-3.11 66 | 1975.0,1.0,4795.295,3143.4,493.212,490.603,3581.9,53.0,276.2,5.53,8.2,215.353,5.32,0.22 67 | 1975.0,2.0,4831.942,3195.8,476.085,486.679,3749.3,54.0,283.7,5.57,8.9,215.973,7.48,-1.91 68 | 1975.0,3.0,4913.328,3241.4,516.402,498.836,3698.6,54.9,285.4,6.27,8.5,216.587,6.61,-0.34 69 | 1975.0,4.0,4977.511,3275.7,530.596,500.141,3736.0,55.8,288.4,5.26,8.3,217.095,6.5,-1.24 70 | 1976.0,1.0,5090.663,3341.2,585.541,495.568,3791.0,56.1,294.7,4.91,7.7,217.528,2.14,2.77 71 | 1976.0,2.0,5128.947,3371.8,610.513,494.532,3822.2,57.0,297.2,5.28,7.6,218.035,6.37,-1.09 72 | 1976.0,3.0,5154.072,3407.5,611.646,493.141,3856.7,57.9,302.0,5.05,7.7,218.644,6.27,-1.22 73 | 1976.0,4.0,5191.499,3451.8,615.898,494.415,3884.4,58.7,308.3,4.57,7.8,219.179,5.49,-0.92 74 | 1977.0,1.0,5251.762,3491.3,646.198,498.509,3887.5,60.0,316.0,4.6,7.5,219.684,8.76,-4.16 75 | 1977.0,2.0,5356.131,3510.6,696.141,506.695,3931.8,60.8,320.2,5.06,7.1,220.239,5.3,-0.24 76 | 1977.0,3.0,5451.921,3544.1,734.078,509.605,3990.8,61.6,326.4,5.82,6.9,220.904,5.23,0.59 77 | 1977.0,4.0,5450.793,3597.5,713.356,504.584,4071.2,62.7,334.4,6.2,6.6,221.477,7.08,-0.88 78 | 1978.0,1.0,5469.405,3618.5,727.504,506.314,4096.4,63.9,339.9,6.34,6.3,221.991,7.58,-1.24 79 | 1978.0,2.0,5684.569,3695.9,777.454,518.366,4143.4,65.5,347.6,6.72,6.0,222.585,9.89,-3.18 80 | 1978.0,3.0,5740.3,3711.4,801.452,520.199,4177.1,67.1,353.3,7.64,6.0,223.271,9.65,-2.01 81 | 1978.0,4.0,5816.222,3741.3,819.689,524.782,4209.8,68.5,358.6,9.02,5.9,223.865,8.26,0.76 82 | 1979.0,1.0,5825.949,3760.2,819.556,525.524,4255.9,70.6,368.0,9.42,5.9,224.438,12.08,-2.66 83 | 1979.0,2.0,5831.418,3758.0,817.66,532.04,4226.1,73.0,377.2,9.3,5.7,225.055,13.37,-4.07 84 | 1979.0,3.0,5873.335,3794.9,801.742,531.232,4250.3,75.2,380.8,10.49,5.9,225.801,11.88,-1.38 85 | 1979.0,4.0,5889.495,3805.0,786.817,531.126,4284.3,78.0,385.8,11.94,5.9,226.451,14.62,-2.68 86 | 1980.0,1.0,5908.467,3798.4,781.114,548.115,4296.2,80.9,383.8,13.75,6.3,227.061,14.6,-0.85 87 | 1980.0,2.0,5787.373,3712.2,710.64,561.895,4236.1,82.6,394.0,7.9,7.3,227.726,8.32,-0.42 88 | 1980.0,3.0,5776.617,3752.0,656.477,554.292,4279.7,84.7,409.0,10.34,7.7,228.417,10.04,0.3 89 | 1980.0,4.0,5883.46,3802.0,723.22,556.13,4368.1,87.2,411.3,14.75,7.4,228.937,11.64,3.11 90 | 1981.0,1.0,6005.717,3822.8,795.091,567.618,4358.1,89.1,427.4,13.95,7.4,229.403,8.62,5.32 91 | 1981.0,2.0,5957.795,3822.8,757.24,584.54,4358.6,91.5,426.9,15.33,7.4,229.966,10.63,4.69 92 | 1981.0,3.0,6030.184,3838.3,804.242,583.89,4455.4,93.4,428.4,14.58,7.4,230.641,8.22,6.36 93 | 1981.0,4.0,5955.062,3809.3,773.053,590.125,4464.4,94.4,442.7,11.33,8.2,231.157,4.26,7.07 94 | 1982.0,1.0,5857.333,3833.9,692.514,591.043,4469.6,95.0,447.1,12.95,8.8,231.645,2.53,10.42 95 | 1982.0,2.0,5889.074,3847.7,691.9,596.403,4500.8,97.5,448.0,11.97,9.4,232.188,10.39,1.58 96 | 1982.0,3.0,5866.37,3877.2,683.825,605.37,4520.6,98.1,464.5,8.1,9.9,232.816,2.45,5.65 97 | 1982.0,4.0,5871.001,3947.9,622.93,623.307,4536.4,97.9,477.2,7.96,10.7,233.322,-0.82,8.77 98 | 1983.0,1.0,5944.02,3986.6,645.11,630.873,4572.2,98.8,493.2,8.22,10.4,233.781,3.66,4.56 99 | 1983.0,2.0,6077.619,4065.7,707.372,644.322,4605.5,99.8,507.8,8.69,10.1,234.307,4.03,4.66 100 | 1983.0,3.0,6197.468,4137.6,754.937,662.412,4674.7,100.8,517.2,8.99,9.4,234.907,3.99,5.01 101 | 1983.0,4.0,6325.574,4203.2,834.427,639.197,4771.1,102.1,525.1,8.89,8.5,235.385,5.13,3.76 102 | 1984.0,1.0,6448.264,4239.2,921.763,644.635,4875.4,103.3,535.0,9.43,7.9,235.839,4.67,4.76 103 | 1984.0,2.0,6559.594,4299.9,952.841,664.839,4959.4,104.1,540.9,9.94,7.5,236.348,3.09,6.85 104 | 1984.0,3.0,6623.343,4333.0,974.989,662.294,5036.6,105.1,543.7,10.19,7.4,236.976,3.82,6.37 105 | 1984.0,4.0,6677.264,4390.1,958.993,684.282,5084.5,105.7,557.0,8.14,7.3,237.468,2.28,5.87 106 | 1985.0,1.0,6740.275,4464.6,927.375,691.613,5072.0,107.0,570.4,8.25,7.3,237.9,4.89,3.36 107 | 1985.0,2.0,6797.344,4505.2,943.383,708.524,5172.7,107.7,589.1,7.17,7.3,238.466,2.61,4.56 108 | 1985.0,3.0,6903.523,4590.8,932.959,732.305,5140.7,108.5,607.8,7.13,7.2,239.113,2.96,4.17 109 | 1985.0,4.0,6955.918,4600.9,969.434,732.026,5193.9,109.9,621.4,7.14,7.0,239.638,5.13,2.01 110 | 1986.0,1.0,7022.757,4639.3,967.442,728.125,5255.8,108.7,641.0,6.56,7.0,240.094,-4.39,10.95 111 | 1986.0,2.0,7050.969,4688.7,945.972,751.334,5315.5,109.5,670.3,6.06,7.2,240.651,2.93,3.13 112 | 1986.0,3.0,7118.95,4770.7,916.315,779.77,5343.3,110.2,694.9,5.31,7.0,241.274,2.55,2.76 113 | 1986.0,4.0,7153.359,4799.4,917.736,767.671,5346.5,111.4,730.2,5.44,6.8,241.784,4.33,1.1 114 | 1987.0,1.0,7193.019,4792.1,945.776,772.247,5379.4,112.7,743.9,5.61,6.6,242.252,4.64,0.97 115 | 1987.0,2.0,7269.51,4856.3,947.1,782.962,5321.0,113.8,743.0,5.67,6.3,242.804,3.89,1.79 116 | 1987.0,3.0,7332.558,4910.4,948.055,783.804,5416.2,115.0,756.2,6.19,6.0,243.446,4.2,1.99 117 | 1987.0,4.0,7458.022,4922.2,1021.98,795.467,5493.1,116.0,756.2,5.76,5.9,243.981,3.46,2.29 118 | 1988.0,1.0,7496.6,5004.4,964.398,773.851,5562.1,117.2,768.1,5.76,5.7,244.445,4.12,1.64 119 | 1988.0,2.0,7592.881,5040.8,987.858,765.98,5614.3,118.5,781.4,6.48,5.5,245.021,4.41,2.07 120 | 1988.0,3.0,7632.082,5080.6,994.204,760.245,5657.5,119.9,783.3,7.22,5.5,245.693,4.7,2.52 121 | 1988.0,4.0,7733.991,5140.4,1007.371,783.065,5708.5,121.2,785.7,8.03,5.3,246.224,4.31,3.72 122 | 1989.0,1.0,7806.603,5159.3,1045.975,767.024,5773.4,123.1,779.2,8.67,5.2,246.721,6.22,2.44 123 | 1989.0,2.0,7865.016,5182.4,1033.753,784.275,5749.8,124.5,777.8,8.15,5.2,247.342,4.52,3.63 124 | 1989.0,3.0,7927.393,5236.1,1021.604,791.819,5787.0,125.4,786.6,7.76,5.3,248.067,2.88,4.88 125 | 1989.0,4.0,7944.697,5261.7,1011.119,787.844,5831.3,127.5,795.4,7.65,5.4,248.659,6.64,1.01 126 | 1990.0,1.0,8027.693,5303.3,1021.07,799.681,5875.1,128.9,806.2,7.8,5.3,249.306,4.37,3.44 127 | 1990.0,2.0,8059.598,5320.8,1021.36,800.639,5913.9,130.5,810.1,7.7,5.3,250.132,4.93,2.76 128 | 1990.0,3.0,8059.476,5341.0,997.319,793.513,5918.1,133.4,819.8,7.33,5.7,251.057,8.79,-1.46 129 | 1990.0,4.0,7988.864,5299.5,934.248,800.525,5878.2,134.7,827.2,6.67,6.1,251.889,3.88,2.79 130 | 1991.0,1.0,7950.164,5284.4,896.21,806.775,5896.3,135.1,843.2,5.83,6.6,252.643,1.19,4.65 131 | 1991.0,2.0,8003.822,5324.7,891.704,809.081,5941.1,136.2,861.5,5.54,6.8,253.493,3.24,2.29 132 | 1991.0,3.0,8037.538,5345.0,913.904,793.987,5953.6,137.2,878.0,5.18,6.9,254.435,2.93,2.25 133 | 1991.0,4.0,8069.046,5342.6,948.891,778.378,5992.4,138.3,910.4,4.14,7.1,255.214,3.19,0.95 134 | 1992.0,1.0,8157.616,5434.5,927.796,778.568,6082.9,139.4,943.8,3.88,7.4,255.992,3.17,0.71 135 | 1992.0,2.0,8244.294,5466.7,988.912,777.762,6129.5,140.5,963.2,3.5,7.6,256.894,3.14,0.36 136 | 1992.0,3.0,8329.361,5527.1,999.135,786.639,6160.6,141.7,1003.8,2.97,7.6,257.861,3.4,-0.44 137 | 1992.0,4.0,8417.016,5594.6,1030.758,787.064,6248.2,142.8,1030.4,3.12,7.4,258.679,3.09,0.02 138 | 1993.0,1.0,8432.485,5617.2,1054.979,762.901,6156.5,143.8,1047.6,2.92,7.2,259.414,2.79,0.13 139 | 1993.0,2.0,8486.435,5671.1,1063.263,752.158,6252.3,144.5,1084.5,3.02,7.1,260.255,1.94,1.08 140 | 1993.0,3.0,8531.108,5732.7,1062.514,744.227,6265.7,145.6,1113.0,3.0,6.8,261.163,3.03,-0.04 141 | 1993.0,4.0,8643.769,5783.7,1118.583,748.102,6358.1,146.3,1131.6,3.05,6.6,261.919,1.92,1.13 142 | 1994.0,1.0,8727.919,5848.1,1166.845,721.288,6332.6,147.2,1141.1,3.48,6.6,262.631,2.45,1.02 143 | 1994.0,2.0,8847.303,5891.5,1234.855,717.197,6440.6,148.4,1150.5,4.2,6.2,263.436,3.25,0.96 144 | 1994.0,3.0,8904.289,5938.7,1212.655,736.89,6487.9,149.4,1150.1,4.68,6.0,264.301,2.69,2.0 145 | 1994.0,4.0,9003.18,5997.3,1269.19,716.702,6574.0,150.5,1151.4,5.53,5.6,265.044,2.93,2.6 146 | 1995.0,1.0,9025.267,6004.3,1282.09,715.326,6616.6,151.8,1149.3,5.72,5.5,265.755,3.44,2.28 147 | 1995.0,2.0,9044.668,6053.5,1247.61,712.492,6617.2,152.6,1145.4,5.52,5.7,266.557,2.1,3.42 148 | 1995.0,3.0,9120.684,6107.6,1235.601,707.649,6666.8,153.5,1137.3,5.32,5.7,267.456,2.35,2.97 149 | 1995.0,4.0,9184.275,6150.6,1270.392,681.081,6706.2,154.7,1123.5,5.17,5.6,268.151,3.11,2.05 150 | 1996.0,1.0,9247.188,6206.9,1287.128,695.265,6777.7,156.1,1124.8,4.91,5.5,268.853,3.6,1.31 151 | 1996.0,2.0,9407.052,6277.1,1353.795,705.172,6850.6,157.0,1112.4,5.09,5.5,269.667,2.3,2.79 152 | 1996.0,3.0,9488.879,6314.6,1422.059,692.741,6908.9,158.2,1086.1,5.04,5.3,270.581,3.05,2.0 153 | 1996.0,4.0,9592.458,6366.1,1418.193,690.744,6946.8,159.4,1081.5,4.99,5.3,271.36,3.02,1.97 154 | 1997.0,1.0,9666.235,6430.2,1451.304,681.445,7008.9,159.9,1063.8,5.1,5.2,272.083,1.25,3.85 155 | 1997.0,2.0,9809.551,6456.2,1543.976,693.525,7061.5,160.4,1066.2,5.01,5.0,272.912,1.25,3.76 156 | 1997.0,3.0,9932.672,6566.0,1571.426,691.261,7142.4,161.5,1065.5,5.02,4.9,273.852,2.73,2.29 157 | 1997.0,4.0,10008.874,6641.1,1596.523,690.311,7241.5,162.0,1074.4,5.11,4.7,274.626,1.24,3.88 158 | 1998.0,1.0,10103.425,6707.2,1672.732,668.783,7406.2,162.2,1076.1,5.02,4.6,275.304,0.49,4.53 159 | 1998.0,2.0,10194.277,6822.6,1652.716,687.184,7512.0,163.2,1075.0,4.98,4.4,276.115,2.46,2.52 160 | 1998.0,3.0,10328.787,6913.1,1700.071,681.472,7591.0,163.9,1086.0,4.49,4.5,277.003,1.71,2.78 161 | 1998.0,4.0,10507.575,7019.1,1754.743,688.147,7646.5,164.7,1097.8,4.38,4.4,277.79,1.95,2.43 162 | 1999.0,1.0,10601.179,7088.3,1809.993,683.601,7698.4,165.9,1101.9,4.39,4.3,278.451,2.9,1.49 163 | 1999.0,2.0,10684.049,7199.9,1803.674,683.594,7716.0,166.7,1098.7,4.54,4.3,279.295,1.92,2.62 164 | 1999.0,3.0,10819.914,7286.4,1848.949,697.936,7765.9,168.1,1102.3,4.75,4.2,280.203,3.35,1.41 165 | 1999.0,4.0,11014.254,7389.2,1914.567,713.445,7887.7,169.3,1121.9,5.2,4.1,280.976,2.85,2.35 166 | 2000.0,1.0,11043.044,7501.3,1887.836,685.216,8053.4,170.9,1113.5,5.63,4.0,281.653,3.76,1.87 167 | 2000.0,2.0,11258.454,7571.8,2018.529,712.641,8135.9,172.7,1103.0,5.81,3.9,282.385,4.19,1.62 168 | 2000.0,3.0,11267.867,7645.9,1986.956,698.827,8222.3,173.9,1098.7,6.07,4.0,283.19,2.77,3.3 169 | 2000.0,4.0,11334.544,7713.5,1987.845,695.597,8234.6,175.6,1097.7,5.7,3.9,283.9,3.89,1.81 170 | 2001.0,1.0,11297.171,7744.3,1882.691,710.403,8296.5,176.4,1114.9,4.39,4.2,284.55,1.82,2.57 171 | 2001.0,2.0,11371.251,7773.5,1876.65,725.623,8273.7,177.4,1139.7,3.54,4.4,285.267,2.26,1.28 172 | 2001.0,3.0,11340.075,7807.7,1837.074,730.493,8484.5,177.6,1166.0,2.72,4.8,286.047,0.45,2.27 173 | 2001.0,4.0,11380.128,7930.0,1731.189,739.318,8385.5,177.7,1190.9,1.74,5.5,286.728,0.23,1.51 174 | 2002.0,1.0,11477.868,7957.3,1789.327,756.915,8611.6,179.3,1185.9,1.75,5.7,287.328,3.59,-1.84 175 | 2002.0,2.0,11538.77,7997.8,1810.779,774.408,8658.9,180.0,1199.5,1.7,5.8,288.028,1.56,0.14 176 | 2002.0,3.0,11596.43,8052.0,1814.531,786.673,8629.2,181.2,1204.0,1.61,5.7,288.783,2.66,-1.05 177 | 2002.0,4.0,11598.824,8080.6,1813.219,799.967,8649.6,182.6,1226.8,1.2,5.8,289.421,3.08,-1.88 178 | 2003.0,1.0,11645.819,8122.3,1813.141,800.196,8681.3,183.2,1248.4,1.14,5.9,290.019,1.31,-0.17 179 | 2003.0,2.0,11738.706,8197.8,1823.698,838.775,8812.5,183.7,1287.9,0.96,6.2,290.704,1.09,-0.13 180 | 2003.0,3.0,11935.461,8312.1,1889.883,839.598,8935.4,184.9,1297.3,0.94,6.1,291.449,2.6,-1.67 181 | 2003.0,4.0,12042.817,8358.0,1959.783,845.722,8986.4,186.3,1306.1,0.9,5.8,292.057,3.02,-2.11 182 | 2004.0,1.0,12127.623,8437.6,1970.015,856.57,9025.9,187.4,1332.1,0.94,5.7,292.635,2.35,-1.42 183 | 2004.0,2.0,12213.818,8483.2,2055.58,861.44,9115.0,189.1,1340.5,1.21,5.6,293.31,3.61,-2.41 184 | 2004.0,3.0,12303.533,8555.8,2082.231,876.385,9175.9,190.8,1361.0,1.63,5.4,294.066,3.58,-1.95 185 | 2004.0,4.0,12410.282,8654.2,2125.152,865.596,9303.4,191.8,1366.6,2.2,5.4,294.741,2.09,0.11 186 | 2005.0,1.0,12534.113,8719.0,2170.299,869.204,9189.6,193.8,1357.8,2.69,5.3,295.308,4.15,-1.46 187 | 2005.0,2.0,12587.535,8802.9,2131.468,870.044,9253.0,194.7,1366.6,3.01,5.1,295.994,1.85,1.16 188 | 2005.0,3.0,12683.153,8865.6,2154.949,890.394,9308.0,199.2,1375.0,3.52,5.0,296.77,9.14,-5.62 189 | 2005.0,4.0,12748.699,8888.5,2232.193,875.557,9358.7,199.4,1380.6,4.0,4.9,297.435,0.4,3.6 190 | 2006.0,1.0,12915.938,8986.6,2264.721,900.511,9533.8,200.7,1380.5,4.51,4.7,298.061,2.6,1.91 191 | 2006.0,2.0,12962.462,9035.0,2261.247,892.839,9617.3,202.7,1369.2,4.82,4.7,298.766,3.97,0.85 192 | 2006.0,3.0,12965.916,9090.7,2229.636,892.002,9662.5,201.9,1369.4,4.9,4.7,299.593,-1.58,6.48 193 | 2006.0,4.0,13060.679,9181.6,2165.966,894.404,9788.8,203.574,1373.6,4.92,4.4,300.32,3.3,1.62 194 | 2007.0,1.0,13099.901,9265.1,2132.609,882.766,9830.2,205.92,1379.7,4.95,4.5,300.977,4.58,0.36 195 | 2007.0,2.0,13203.977,9291.5,2162.214,898.713,9842.7,207.338,1370.0,4.72,4.5,301.714,2.75,1.97 196 | 2007.0,3.0,13321.109,9335.6,2166.491,918.983,9883.9,209.133,1379.2,4.0,4.7,302.509,3.45,0.55 197 | 2007.0,4.0,13391.249,9363.6,2123.426,925.11,9886.2,212.495,1377.4,3.01,4.8,303.204,6.38,-3.37 198 | 2008.0,1.0,13366.865,9349.6,2082.886,943.372,9826.8,213.997,1384.0,1.56,4.9,303.803,2.82,-1.26 199 | 2008.0,2.0,13415.266,9351.0,2026.518,961.28,10059.0,218.61,1409.3,1.74,5.4,304.483,8.53,-6.79 200 | 2008.0,3.0,13324.6,9267.7,1990.693,991.551,9838.3,216.889,1474.7,1.17,6.0,305.27,-3.16,4.33 201 | 2008.0,4.0,13141.92,9195.3,1857.661,1007.273,9920.4,212.174,1576.5,0.12,6.9,305.952,-8.79,8.91 202 | 2009.0,1.0,12925.41,9209.2,1558.494,996.287,9926.4,212.671,1592.8,0.22,8.1,306.547,0.94,-0.71 203 | 2009.0,2.0,12901.504,9189.0,1456.678,1023.528,10077.5,214.469,1653.6,0.18,9.2,307.226,3.37,-3.19 204 | 2009.0,3.0,12990.341,9256.0,1486.398,1044.088,10040.6,216.385,1673.9,0.12,9.6,308.013,3.56,-3.44 205 | -------------------------------------------------------------------------------- /data/myzip.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Python-Big-Data-Science-NYC/PythonDataScienceBootcampNYC/4bae79d5cc9fe4268dd4f4ac8e3acfeaf8ad8634/data/myzip.zip -------------------------------------------------------------------------------- /data/salary.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Python-Big-Data-Science-NYC/PythonDataScienceBootcampNYC/4bae79d5cc9fe4268dd4f4ac8e3acfeaf8ad8634/data/salary.xlsx -------------------------------------------------------------------------------- /dataJuly8.csv: -------------------------------------------------------------------------------- 1 | message,a,b,c,d 2 | hello,1,2,3,4 3 | world,5,6,7,8 4 | foo,9,10,11,12 5 | -------------------------------------------------------------------------------- /df1pickle.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Python-Big-Data-Science-NYC/PythonDataScienceBootcampNYC/4bae79d5cc9fe4268dd4f4ac8e3acfeaf8ad8634/df1pickle.p -------------------------------------------------------------------------------- /dummydata - Sheet1.csv: -------------------------------------------------------------------------------- 1 | SiteName,TypeofSite,Location,ApprovedorNot,NumerofClinicians 2 | BLEU,PC,Queens,Yes,2 3 | XXX,BH,Brooklyn,No,2 4 | YYY,PC,Manhattan,Yes,3 5 | ABC,BH,Staten Islan,No,4 6 | GGG,PC,Queens,Yes,2 7 | HHH,BH,Brooklyn,No,2 8 | ASD,PC,Manhattan,Yes,3 9 | SDF,BH,Staten Islan,No,4 10 | DSA,PC,Queens,Yes,2 11 | FDF,BH,Brooklyn,No,3 12 | FDF,PC,Manhattan,Yes,2 -------------------------------------------------------------------------------- /dummydata - Sheet2.csv: -------------------------------------------------------------------------------- 1 | City,Spanish,English,Hindi,Urdu,Russian,French 2 | Queens,51.94126674,556.500464,521.7870947,114.7293645,389.188901,860.5095947 3 | Manhattan,943.6593379,411.7363975,659.9105586,416.308176,81.30237616,400.9050879 4 | Brooklyn,666.6360011,139.8603267,611.0708759,490.8616905,714.6984318,938.367326 -------------------------------------------------------------------------------- /ex15_sample.txt: -------------------------------------------------------------------------------- 1 | This is stuff I typed into a file. 2 | It is really cool stuff. 3 | Lots and lots of fun to have in here. -------------------------------------------------------------------------------- /joshi.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Python-Big-Data-Science-NYC/PythonDataScienceBootcampNYC/4bae79d5cc9fe4268dd4f4ac8e3acfeaf8ad8634/joshi.p -------------------------------------------------------------------------------- /june/10june.csv: -------------------------------------------------------------------------------- 1 | Name,Distance_Traveled,Source,City 2 | A,15,Meetup,Queens 3 | B,20,Manahttan,Brooklyn 4 | C,5,Meetup,Queens 5 | D,1,Meetup,Queens -------------------------------------------------------------------------------- /june/22JunePart2.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 2, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "data": { 10 | "text/html": [ 11 | "
\n", 12 | "\n", 25 | "\n", 26 | " \n", 27 | " \n", 28 | " \n", 29 | " \n", 30 | " \n", 31 | " \n", 32 | " \n", 33 | " \n", 34 | " \n", 35 | " \n", 36 | " \n", 37 | " \n", 38 | " \n", 39 | " \n", 40 | " \n", 41 | " \n", 42 | " \n", 43 | " \n", 44 | " \n", 45 | " \n", 46 | " \n", 47 | " \n", 48 | " \n", 49 | " \n", 50 | " \n", 51 | " \n", 52 | " \n", 53 | " \n", 54 | " \n", 55 | " \n", 56 | " \n", 57 | " \n", 58 | " \n", 59 | " \n", 60 | " \n", 61 | " \n", 62 | " \n", 63 | " \n", 64 | " \n", 65 | " \n", 66 | " \n", 67 | " \n", 68 | " \n", 69 | " \n", 70 | " \n", 71 | " \n", 72 | "
NameAgbeCity
0A24Queens
1B34Manhattan
2C30Queens
3D34Manhattan
4E34Manhattan
5F20Manhattan
\n", 73 | "
" 74 | ], 75 | "text/plain": [ 76 | " Name Agbe City\n", 77 | "0 A 24 Queens\n", 78 | "1 B 34 Manhattan\n", 79 | "2 C 30 Queens\n", 80 | "3 D 34 Manhattan\n", 81 | "4 E 34 Manhattan\n", 82 | "5 F 20 Manhattan" 83 | ] 84 | }, 85 | "execution_count": 2, 86 | "metadata": {}, 87 | "output_type": "execute_result" 88 | } 89 | ], 90 | "source": [ 91 | "import pandas as pd\n", 92 | "\n", 93 | "pd.read_csv('Book3.csv')" 94 | ] 95 | }, 96 | { 97 | "cell_type": "code", 98 | "execution_count": 11, 99 | "metadata": {}, 100 | "outputs": [], 101 | "source": [ 102 | "joshidf = pd.read_csv('http://blockchainainyc.com/wp-content/uploads/2018/06/pandas17june.csv')" 103 | ] 104 | }, 105 | { 106 | "cell_type": "code", 107 | "execution_count": 5, 108 | "metadata": {}, 109 | "outputs": [ 110 | { 111 | "data": { 112 | "text/html": [ 113 | "
\n", 114 | "\n", 127 | "\n", 128 | " \n", 129 | " \n", 130 | " \n", 131 | " \n", 132 | " \n", 133 | " \n", 134 | " \n", 135 | " \n", 136 | " \n", 137 | " \n", 138 | " \n", 139 | " \n", 140 | " \n", 141 | " \n", 142 | " \n", 143 | " \n", 144 | " \n", 145 | " \n", 146 | " \n", 147 | " \n", 148 | " \n", 149 | " \n", 150 | " \n", 151 | " \n", 152 | " \n", 153 | " \n", 154 | " \n", 155 | " \n", 156 | " \n", 157 | " \n", 158 | " \n", 159 | " \n", 160 | " \n", 161 | " \n", 162 | " \n", 163 | " \n", 164 | " \n", 165 | " \n", 166 | " \n", 167 | " \n", 168 | " \n", 169 | " \n", 170 | " \n", 171 | " \n", 172 | " \n", 173 | " \n", 174 | " \n", 175 | " \n", 176 | " \n", 177 | "
NameCityAgeSalaryGenderDistance
0AM3212312M10
1BB34231231F14
2CQ54321321F32
3DM4332131M21
\n", 178 | "
" 179 | ], 180 | "text/plain": [ 181 | " Name City Age Salary Gender Distance\n", 182 | "0 A M 32 12312 M 10\n", 183 | "1 B B 34 231231 F 14\n", 184 | "2 C Q 54 321321 F 32\n", 185 | "3 D M 43 32131 M 21" 186 | ] 187 | }, 188 | "execution_count": 5, 189 | "metadata": {}, 190 | "output_type": "execute_result" 191 | } 192 | ], 193 | "source": [ 194 | "joshidf" 195 | ] 196 | }, 197 | { 198 | "cell_type": "code", 199 | "execution_count": 7, 200 | "metadata": {}, 201 | "outputs": [], 202 | "source": [ 203 | "joshidf.to_pickle('joshi.p')" 204 | ] 205 | }, 206 | { 207 | "cell_type": "code", 208 | "execution_count": 8, 209 | "metadata": {}, 210 | "outputs": [ 211 | { 212 | "data": { 213 | "text/html": [ 214 | "
\n", 215 | "\n", 228 | "\n", 229 | " \n", 230 | " \n", 231 | " \n", 232 | " \n", 233 | " \n", 234 | " \n", 235 | " \n", 236 | " \n", 237 | " \n", 238 | " \n", 239 | " \n", 240 | " \n", 241 | " \n", 242 | " \n", 243 | " \n", 244 | " \n", 245 | " \n", 246 | " \n", 247 | " \n", 248 | " \n", 249 | " \n", 250 | " \n", 251 | " \n", 252 | " \n", 253 | " \n", 254 | " \n", 255 | " \n", 256 | " \n", 257 | " \n", 258 | " \n", 259 | " \n", 260 | " \n", 261 | " \n", 262 | " \n", 263 | " \n", 264 | " \n", 265 | " \n", 266 | " \n", 267 | " \n", 268 | " \n", 269 | " \n", 270 | " \n", 271 | " \n", 272 | " \n", 273 | " \n", 274 | " \n", 275 | " \n", 276 | " \n", 277 | " \n", 278 | "
NameCityAgeSalaryGenderDistance
0AM3212312M10
1BB34231231F14
2CQ54321321F32
3DM4332131M21
\n", 279 | "
" 280 | ], 281 | "text/plain": [ 282 | " Name City Age Salary Gender Distance\n", 283 | "0 A M 32 12312 M 10\n", 284 | "1 B B 34 231231 F 14\n", 285 | "2 C Q 54 321321 F 32\n", 286 | "3 D M 43 32131 M 21" 287 | ] 288 | }, 289 | "execution_count": 8, 290 | "metadata": {}, 291 | "output_type": "execute_result" 292 | } 293 | ], 294 | "source": [ 295 | "joshidf" 296 | ] 297 | }, 298 | { 299 | "cell_type": "code", 300 | "execution_count": 13, 301 | "metadata": {}, 302 | "outputs": [ 303 | { 304 | "data": { 305 | "text/html": [ 306 | "
\n", 307 | "\n", 320 | "\n", 321 | " \n", 322 | " \n", 323 | " \n", 324 | " \n", 325 | " \n", 326 | " \n", 327 | " \n", 328 | " \n", 329 | " \n", 330 | " \n", 331 | " \n", 332 | " \n", 333 | " \n", 334 | " \n", 335 | " \n", 336 | " \n", 337 | " \n", 338 | " \n", 339 | " \n", 340 | " \n", 341 | " \n", 342 | " \n", 343 | " \n", 344 | " \n", 345 | " \n", 346 | " \n", 347 | " \n", 348 | " \n", 349 | " \n", 350 | " \n", 351 | " \n", 352 | "
NameCityAgeSalaryGenderDistance
0AM3212312M10
3DM4332131M21
\n", 353 | "
" 354 | ], 355 | "text/plain": [ 356 | " Name City Age Salary Gender Distance\n", 357 | "0 A M 32 12312 M 10\n", 358 | "3 D M 43 32131 M 21" 359 | ] 360 | }, 361 | "execution_count": 13, 362 | "metadata": {}, 363 | "output_type": "execute_result" 364 | } 365 | ], 366 | "source": [ 367 | "#select * from joshidf where city = 'M'\n", 368 | "# Excel filter, using drup down\n", 369 | "\n", 370 | "joshidf [joshidf['City'] == 'M']\n" 371 | ] 372 | }, 373 | { 374 | "cell_type": "code", 375 | "execution_count": 14, 376 | "metadata": {}, 377 | "outputs": [ 378 | { 379 | "data": { 380 | "text/plain": [ 381 | "0 True\n", 382 | "1 False\n", 383 | "2 False\n", 384 | "3 True\n", 385 | "Name: City, dtype: bool" 386 | ] 387 | }, 388 | "execution_count": 14, 389 | "metadata": {}, 390 | "output_type": "execute_result" 391 | } 392 | ], 393 | "source": [ 394 | "joshidf['City'] == 'M'" 395 | ] 396 | }, 397 | { 398 | "cell_type": "code", 399 | "execution_count": null, 400 | "metadata": {}, 401 | "outputs": [], 402 | "source": [] 403 | } 404 | ], 405 | "metadata": { 406 | "kernelspec": { 407 | "display_name": "Python 3.6", 408 | "language": "python", 409 | "name": "python36" 410 | }, 411 | "language_info": { 412 | "codemirror_mode": { 413 | "name": "ipython", 414 | "version": 3 415 | }, 416 | "file_extension": ".py", 417 | "mimetype": "text/x-python", 418 | "name": "python", 419 | "nbconvert_exporter": "python", 420 | "pygments_lexer": "ipython3", 421 | "version": "3.6.3" 422 | } 423 | }, 424 | "nbformat": 4, 425 | "nbformat_minor": 2 426 | } 427 | -------------------------------------------------------------------------------- /june/Part110JunePython.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stdout", 10 | "output_type": "stream", 11 | "text": [ 12 | "Hello World!\n", 13 | "Hello Again\n", 14 | "I like typing this.\n", 15 | "This is fun.\n", 16 | "Yay! Printing.\n", 17 | "I'd much rather you 'not'.\n", 18 | "I \"said\" do not touch this.\n" 19 | ] 20 | } 21 | ], 22 | "source": [ 23 | "print(\"Hello World!\")\n", 24 | "print(\"Hello Again\")\n", 25 | "print(\"I like typing this.\")\n", 26 | "print(\"This is fun.\")\n", 27 | "print('Yay! Printing.')\n", 28 | "print(\"I'd much rather you 'not'.\")\n", 29 | "print('I \"said\" do not touch this.')" 30 | ] 31 | }, 32 | { 33 | "cell_type": "code", 34 | "execution_count": 6, 35 | "metadata": {}, 36 | "outputs": [ 37 | { 38 | "name": "stdout", 39 | "output_type": "stream", 40 | "text": [ 41 | "a\"m\n" 42 | ] 43 | } 44 | ], 45 | "source": [ 46 | "print('a\"m')" 47 | ] 48 | }, 49 | { 50 | "cell_type": "code", 51 | "execution_count": 7, 52 | "metadata": {}, 53 | "outputs": [ 54 | { 55 | "name": "stdout", 56 | "output_type": "stream", 57 | "text": [ 58 | "Hello World!Hello Again\n" 59 | ] 60 | } 61 | ], 62 | "source": [ 63 | "print(\"Hello World!\"+\"Hello Again\")" 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "execution_count": 8, 69 | "metadata": {}, 70 | "outputs": [ 71 | { 72 | "name": "stdout", 73 | "output_type": "stream", 74 | "text": [ 75 | "Hello World! Hello Again\n" 76 | ] 77 | } 78 | ], 79 | "source": [ 80 | "print(\"Hello World!\",\"Hello Again\")" 81 | ] 82 | }, 83 | { 84 | "cell_type": "code", 85 | "execution_count": 9, 86 | "metadata": {}, 87 | "outputs": [ 88 | { 89 | "name": "stdout", 90 | "output_type": "stream", 91 | "text": [ 92 | "There are 100 cars available.\n", 93 | "There are only 30 drivers available.\n", 94 | "There will be 70 empty cars today\n", 95 | "We can transport 120.0 people today.\n", 96 | "We have 90 to carpool today.\n", 97 | "We need to put about 3.0 in each car.\n" 98 | ] 99 | } 100 | ], 101 | "source": [ 102 | "cars = 100\n", 103 | "space_in_a_car = 4.0\n", 104 | "drivers = 30\n", 105 | "passengers = 90\n", 106 | "cars_not_driven = cars - drivers\n", 107 | "cars_driven = drivers\n", 108 | "carpool_capacity = cars_driven * space_in_a_car\n", 109 | "average_passengers_per_car = passengers / cars_driven\n", 110 | "\n", 111 | "print(\"There are\", cars, \"cars available.\")\n", 112 | "print(\"There are only\", drivers, \"drivers available.\")\n", 113 | "print(\"There will be\", cars_not_driven, \"empty cars today\")\n", 114 | "print(\"We can transport\", carpool_capacity, \"people today.\")\n", 115 | "print(\"We have\", passengers, \"to carpool today.\")\n", 116 | "print(\"We need to put about\", average_passengers_per_car, \"in each car.\")" 117 | ] 118 | }, 119 | { 120 | "cell_type": "code", 121 | "execution_count": 13, 122 | "metadata": {}, 123 | "outputs": [ 124 | { 125 | "name": "stdout", 126 | "output_type": "stream", 127 | "text": [ 128 | "There are 100 cars available.\n" 129 | ] 130 | } 131 | ], 132 | "source": [ 133 | "print(\"There are \" + str(cars) + \" cars available.\")\n" 134 | ] 135 | }, 136 | { 137 | "cell_type": "code", 138 | "execution_count": 14, 139 | "metadata": {}, 140 | "outputs": [ 141 | { 142 | "name": "stdout", 143 | "output_type": "stream", 144 | "text": [ 145 | "Let's talk about Zed A. Shaw.\n" 146 | ] 147 | } 148 | ], 149 | "source": [ 150 | "my_name = 'Zed A. Shaw'\n", 151 | "\n", 152 | "print(f\"Let's talk about {my_name}.\")\n", 153 | "print(\"Let's talk about\", my_name,\".\")\n" 154 | ] 155 | }, 156 | { 157 | "cell_type": "code", 158 | "execution_count": 15, 159 | "metadata": {}, 160 | "outputs": [ 161 | { 162 | "name": "stdout", 163 | "output_type": "stream", 164 | "text": [ 165 | "Let's talk about Zed A. Shaw .\n" 166 | ] 167 | } 168 | ], 169 | "source": [ 170 | "print(\"Let's talk about\", my_name,\".\")\n" 171 | ] 172 | }, 173 | { 174 | "cell_type": "code", 175 | "execution_count": 16, 176 | "metadata": {}, 177 | "outputs": [ 178 | { 179 | "name": "stdout", 180 | "output_type": "stream", 181 | "text": [ 182 | "Let's talk about Zed A. Shaw.\n", 183 | "He's 74 inches tall.\n", 184 | "He's 180 pounds heavy.\n", 185 | "Actually that's not too heavy.\n", 186 | "He's got Blue eyes and Brown hair.\n", 187 | "His teeth are usually White depending on the coffee.\n", 188 | "If I add 35, 74, and 180 I get 289.\n" 189 | ] 190 | } 191 | ], 192 | "source": [ 193 | "my_name = 'Zed A. Shaw'\n", 194 | "my_age = 35 # not a lie\n", 195 | "my_height = 74 # inches\n", 196 | "my_weight = 180 # lbs\n", 197 | "my_eyes = 'Blue'\n", 198 | "my_teeth = 'White'\n", 199 | "my_hair = 'Brown'\n", 200 | "\n", 201 | "print(f\"Let's talk about {my_name}.\")\n", 202 | "print(f\"He's {my_height} inches tall.\")\n", 203 | "print(f\"He's {my_weight} pounds heavy.\")\n", 204 | "print(\"Actually that's not too heavy.\")\n", 205 | "print(f\"He's got {my_eyes} eyes and {my_hair} hair.\")\n", 206 | "print(f\"His teeth are usually {my_teeth} depending on the coffee.\")\n", 207 | "\n", 208 | "# this line is tricky, try to get it exactly right\n", 209 | "total = my_age + my_height + my_weight\n", 210 | "print(f\"If I add {my_age}, {my_height}, and {my_weight} I get {total}.\")" 211 | ] 212 | }, 213 | { 214 | "cell_type": "code", 215 | "execution_count": 17, 216 | "metadata": {}, 217 | "outputs": [], 218 | "source": [ 219 | "x= {my_age}" 220 | ] 221 | }, 222 | { 223 | "cell_type": "code", 224 | "execution_count": 18, 225 | "metadata": {}, 226 | "outputs": [ 227 | { 228 | "data": { 229 | "text/plain": [ 230 | "{35}" 231 | ] 232 | }, 233 | "execution_count": 18, 234 | "metadata": {}, 235 | "output_type": "execute_result" 236 | } 237 | ], 238 | "source": [ 239 | "x" 240 | ] 241 | }, 242 | { 243 | "cell_type": "code", 244 | "execution_count": 19, 245 | "metadata": {}, 246 | "outputs": [ 247 | { 248 | "name": "stdout", 249 | "output_type": "stream", 250 | "text": [ 251 | "There are 10 types of people.\n", 252 | "Those who know binary and those who don't.\n", 253 | "I said: There are 10 types of people.\n", 254 | "I also said : 'Those who know binary and those who don't.'.\n", 255 | "Isn't that joke so funny?! False\n", 256 | "This is the left side of...a string with a right side.\n" 257 | ] 258 | } 259 | ], 260 | "source": [ 261 | "types_of_people = 10\n", 262 | "x = f\"There are {types_of_people} types of people.\"\n", 263 | "\n", 264 | "binary = \"binary\"\n", 265 | "do_not = \"don't\"\n", 266 | "y = f\"Those who know {binary} and those who {do_not}.\"\n", 267 | "\n", 268 | "print(x)\n", 269 | "print(y)\n", 270 | "\n", 271 | "print(f\"I said: {x}\")\n", 272 | "print(f\"I also said : '{y}'.\")\n", 273 | "\n", 274 | "hilarious = False\n", 275 | "joke_evaluation = \"Isn't that joke so funny?! {}\"\n", 276 | "\n", 277 | "print(joke_evaluation.format(hilarious))\n", 278 | "\n", 279 | "w = \"This is the left side of...\"\n", 280 | "e = \"a string with a right side.\"\n", 281 | "\n", 282 | "print(w + e)" 283 | ] 284 | }, 285 | { 286 | "cell_type": "code", 287 | "execution_count": 20, 288 | "metadata": {}, 289 | "outputs": [], 290 | "source": [ 291 | "hilarious = True\n", 292 | "joke_evaluation = \"Isn't that joke so funny?! {}\"" 293 | ] 294 | }, 295 | { 296 | "cell_type": "code", 297 | "execution_count": 24, 298 | "metadata": {}, 299 | "outputs": [ 300 | { 301 | "name": "stdout", 302 | "output_type": "stream", 303 | "text": [ 304 | "Isn't that joke so funny?! {}\n" 305 | ] 306 | } 307 | ], 308 | "source": [ 309 | "joke_evaluation = \"Isn't that joke so funny?! {}\"\n", 310 | "\n", 311 | "print(joke_evaluation)" 312 | ] 313 | }, 314 | { 315 | "cell_type": "code", 316 | "execution_count": 28, 317 | "metadata": {}, 318 | "outputs": [ 319 | { 320 | "name": "stdout", 321 | "output_type": "stream", 322 | "text": [ 323 | "How old are you? 12\n", 324 | "How tall are you? 12\n", 325 | "How much do you weight? 32\n", 326 | "So, you're 12 old, 12 tall and 32 heavy.\n" 327 | ] 328 | } 329 | ], 330 | "source": [ 331 | "print(\"How old are you?\", end=' ')\n", 332 | "age = int(input())\n", 333 | "\n", 334 | "print(\"How tall are you?\", end=' ')\n", 335 | "height = input()\n", 336 | "print(\"How much do you weight?\", end=' ')\n", 337 | "weight = input()\n", 338 | "\n", 339 | "print(f\"So, you're {age} old, {height} tall and {weight} heavy.\")" 340 | ] 341 | }, 342 | { 343 | "cell_type": "code", 344 | "execution_count": 29, 345 | "metadata": {}, 346 | "outputs": [ 347 | { 348 | "data": { 349 | "text/plain": [ 350 | "12" 351 | ] 352 | }, 353 | "execution_count": 29, 354 | "metadata": {}, 355 | "output_type": "execute_result" 356 | } 357 | ], 358 | "source": [ 359 | "age" 360 | ] 361 | }, 362 | { 363 | "cell_type": "code", 364 | "execution_count": 27, 365 | "metadata": {}, 366 | "outputs": [ 367 | { 368 | "data": { 369 | "text/plain": [ 370 | "18" 371 | ] 372 | }, 373 | "execution_count": 27, 374 | "metadata": {}, 375 | "output_type": "execute_result" 376 | } 377 | ], 378 | "source": [ 379 | "int(age)" 380 | ] 381 | }, 382 | { 383 | "cell_type": "code", 384 | "execution_count": 31, 385 | "metadata": {}, 386 | "outputs": [ 387 | { 388 | "name": "stdout", 389 | "output_type": "stream", 390 | "text": [ 391 | "How old are you?\n", 392 | "12\n" 393 | ] 394 | } 395 | ], 396 | "source": [ 397 | "print(\"How old are you?\")\n", 398 | "age = int(input())" 399 | ] 400 | }, 401 | { 402 | "cell_type": "code", 403 | "execution_count": 32, 404 | "metadata": {}, 405 | "outputs": [ 406 | { 407 | "name": "stdout", 408 | "output_type": "stream", 409 | "text": [ 410 | "arg1: Zed, arg2: Shaw\n", 411 | "arg1: Zed, arg2: Shaw\n", 412 | "arg1: First!\n", 413 | "I got nothin'.\n" 414 | ] 415 | } 416 | ], 417 | "source": [ 418 | "# this one is like your scripts with argv\n", 419 | "def print_two(*args):\n", 420 | " arg1, arg2 = args\n", 421 | " print(f\"arg1: {arg1}, arg2: {arg2}\")\n", 422 | "\n", 423 | "\n", 424 | "# ok, that *args is actually pointless, we can just do this\n", 425 | "def print_two_again(arg1, arg2):\n", 426 | " print(f\"arg1: {arg1}, arg2: {arg2}\")\n", 427 | "\n", 428 | "\n", 429 | "# this just takes one argument\n", 430 | "def print_one(arg1):\n", 431 | " print(f\"arg1: {arg1}\")\n", 432 | "\n", 433 | "\n", 434 | "# this one takes no arguments\n", 435 | "def print_none():\n", 436 | " print(\"I got nothin'.\")\n", 437 | "\n", 438 | "\n", 439 | "print_two(\"Zed\", \"Shaw\")\n", 440 | "print_two_again(\"Zed\", \"Shaw\")\n", 441 | "print_one(\"First!\")\n", 442 | "print_none()" 443 | ] 444 | }, 445 | { 446 | "cell_type": "code", 447 | "execution_count": 38, 448 | "metadata": {}, 449 | "outputs": [ 450 | { 451 | "name": "stdout", 452 | "output_type": "stream", 453 | "text": [ 454 | "I got nothin'.\n" 455 | ] 456 | } 457 | ], 458 | "source": [ 459 | "print_none()" 460 | ] 461 | }, 462 | { 463 | "cell_type": "code", 464 | "execution_count": 46, 465 | "metadata": {}, 466 | "outputs": [], 467 | "source": [ 468 | "def print_two_again(arg1, arg2):\n", 469 | " print(arg1 + arg2)\n" 470 | ] 471 | }, 472 | { 473 | "cell_type": "code", 474 | "execution_count": 47, 475 | "metadata": {}, 476 | "outputs": [ 477 | { 478 | "name": "stdout", 479 | "output_type": "stream", 480 | "text": [ 481 | "ZedShaw\n" 482 | ] 483 | } 484 | ], 485 | "source": [ 486 | "print_two_again(\"Zed\", \"Shaw\")\n" 487 | ] 488 | }, 489 | { 490 | "cell_type": "code", 491 | "execution_count": 48, 492 | "metadata": {}, 493 | "outputs": [ 494 | { 495 | "name": "stdout", 496 | "output_type": "stream", 497 | "text": [ 498 | "3\n" 499 | ] 500 | } 501 | ], 502 | "source": [ 503 | "print_two_again(1, 2)\n" 504 | ] 505 | }, 506 | { 507 | "cell_type": "code", 508 | "execution_count": 53, 509 | "metadata": {}, 510 | "outputs": [], 511 | "source": [ 512 | "def print_two(*args):\n", 513 | " arg1, arg2, arg3 = args\n", 514 | " print(f\"arg1: {arg1}, arg2: {arg2}\")" 515 | ] 516 | }, 517 | { 518 | "cell_type": "code", 519 | "execution_count": 54, 520 | "metadata": {}, 521 | "outputs": [ 522 | { 523 | "name": "stdout", 524 | "output_type": "stream", 525 | "text": [ 526 | "arg1: Zed, arg2: Shaw\n" 527 | ] 528 | } 529 | ], 530 | "source": [ 531 | "print_two(\"Zed\", \"Shaw\", \"onemore\")\n" 532 | ] 533 | }, 534 | { 535 | "cell_type": "code", 536 | "execution_count": null, 537 | "metadata": {}, 538 | "outputs": [], 539 | "source": [] 540 | } 541 | ], 542 | "metadata": { 543 | "kernelspec": { 544 | "display_name": "Python 3.6", 545 | "language": "python", 546 | "name": "python36" 547 | }, 548 | "language_info": { 549 | "codemirror_mode": { 550 | "name": "ipython", 551 | "version": 3 552 | }, 553 | "file_extension": ".py", 554 | "mimetype": "text/x-python", 555 | "name": "python", 556 | "nbconvert_exporter": "python", 557 | "pygments_lexer": "ipython3", 558 | "version": "3.6.3" 559 | } 560 | }, 561 | "nbformat": 4, 562 | "nbformat_minor": 2 563 | } 564 | -------------------------------------------------------------------------------- /june/pandas17june.csv: -------------------------------------------------------------------------------- 1 | Name,City,Age,Salary,Gender,Distance 2 | A,M,32,12312,M,10 3 | B,B,34,231231,F,14 4 | C,Q,54,321321,F,32 5 | D,M,43,32131,M,21 -------------------------------------------------------------------------------- /june/part2june10.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 5, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "ename": "IndentationError", 10 | "evalue": "expected an indented block (, line 27)", 11 | "output_type": "error", 12 | "traceback": [ 13 | "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m27\u001b[0m\n\u001b[0;31m print(\"People are dogs.\")\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mIndentationError\u001b[0m\u001b[0;31m:\u001b[0m expected an indented block\n" 14 | ] 15 | } 16 | ], 17 | "source": [ 18 | "people = 20\n", 19 | "cats = 30\n", 20 | "dogs = 15\n", 21 | "\n", 22 | "if people < cats:\n", 23 | " print(\"Too many cats! The world is doomed!\")\n", 24 | "\n", 25 | "if people > cats:\n", 26 | " print(\"Not many cats! The world is saved!\")\n", 27 | "\n", 28 | "if people < dogs:\n", 29 | " print(\"The world is drooled on!\")\n", 30 | "\n", 31 | "if people > dogs:\n", 32 | " print(\"The world is dry!\")\n", 33 | "\n", 34 | "dogs += 5\n", 35 | "\n", 36 | "\n", 37 | "if people >= dogs:\n", 38 | " print(\"People are greater than or equal to dogs.\")\n", 39 | "\n", 40 | "if people <= dogs:\n", 41 | " print(\"People are less than or equal to dogs.\")\n", 42 | "\n", 43 | "if people == dogs:\n", 44 | " print(\"People are dogs.\")" 45 | ] 46 | }, 47 | { 48 | "cell_type": "code", 49 | "execution_count": 2, 50 | "metadata": {}, 51 | "outputs": [], 52 | "source": [ 53 | "x=1" 54 | ] 55 | }, 56 | { 57 | "cell_type": "code", 58 | "execution_count": 4, 59 | "metadata": {}, 60 | "outputs": [ 61 | { 62 | "data": { 63 | "text/plain": [ 64 | "False" 65 | ] 66 | }, 67 | "execution_count": 4, 68 | "metadata": {}, 69 | "output_type": "execute_result" 70 | } 71 | ], 72 | "source": [ 73 | "x==" 74 | ] 75 | }, 76 | { 77 | "cell_type": "code", 78 | "execution_count": 8, 79 | "metadata": {}, 80 | "outputs": [], 81 | "source": [ 82 | "people = 20\n", 83 | "cats = 30\n", 84 | "dogs = 15\n", 85 | "\n", 86 | "if people < cats:\n", 87 | " pass\n", 88 | "\n", 89 | "\n" 90 | ] 91 | }, 92 | { 93 | "cell_type": "code", 94 | "execution_count": 13, 95 | "metadata": {}, 96 | "outputs": [ 97 | { 98 | "name": "stdout", 99 | "output_type": "stream", 100 | "text": [ 101 | "You enter a dark room with two doors.\n", 102 | "Do you go through door #1 or door #2?\n", 103 | "> 1\n", 104 | "There's a giant bear here eating a cheese cake.\n", 105 | "What do you do?\n", 106 | "1. Take the cake.\n", 107 | "2. Scream at the bear.\n", 108 | "> 777\n", 109 | "Well, doing 777 is probably better.\n", 110 | "Bear runs away.\n" 111 | ] 112 | } 113 | ], 114 | "source": [ 115 | "print(\"You enter a dark room with two doors.\")\n", 116 | "print(\"Do you go through door #1 or door #2?\")\n", 117 | "\n", 118 | "door = input(\"> \")\n", 119 | "\n", 120 | "if door == \"1\":\n", 121 | " print(\"There's a giant bear here eating a cheese cake.\")\n", 122 | " print(\"What do you do?\")\n", 123 | " print(\"1. Take the cake.\")\n", 124 | " print(\"2. Scream at the bear.\")\n", 125 | "\n", 126 | " bear = input(\"> \")\n", 127 | "\n", 128 | " if bear == \"1\":\n", 129 | " print(\"The bear eats your face off. Good job!\")\n", 130 | " elif bear == \"2\":\n", 131 | " print(\"The bear eats your legs off. Good job!\")\n", 132 | " else:\n", 133 | " print(f\"Well, doing {bear} is probably better.\")\n", 134 | " print(\"Bear runs away.\")\n", 135 | "\n", 136 | "elif door == \"2\":\n", 137 | " print(\"You stare into the endless abyss at Cthulhu's retina.\")\n", 138 | " print(\"1. Blueberries.\")\n", 139 | " print(\"2. Yellow jacket clothespins.\")\n", 140 | " print(\"3. Understanding revolvers yelling melodies.\")\n", 141 | "\n", 142 | " insanity = input(\"> \")\n", 143 | "\n", 144 | " if insanity == \"1\" or insanity == \"2\":\n", 145 | " print(\"Your body survives powered by a mind of jello.\")\n", 146 | " print(\"Good job!\")\n", 147 | " else:\n", 148 | " print(\"The insanity rots your eyes into a pool of muck.\")\n", 149 | " print(\"Good job!\")\n", 150 | "\n", 151 | "else:\n", 152 | " print(\"You stumble around and fall on knife and die. Good job!\")" 153 | ] 154 | }, 155 | { 156 | "cell_type": "code", 157 | "execution_count": 21, 158 | "metadata": {}, 159 | "outputs": [ 160 | { 161 | "name": "stdout", 162 | "output_type": "stream", 163 | "text": [ 164 | "This is count 1\n", 165 | "This is count 2\n", 166 | "This is count 3\n", 167 | "This is count 4\n", 168 | "This is count 5\n", 169 | "A fruit of type: apples\n", 170 | "A fruit of type: oranges\n", 171 | "A fruit of type: pears\n", 172 | "A fruit of type: apricots\n", 173 | "I got 1\n", 174 | "I got pennies\n", 175 | "I got 2\n", 176 | "I got dimes\n", 177 | "I got 3\n", 178 | "I got quarters\n", 179 | "Adding 0 to the list.\n", 180 | "Adding 1 to the list.\n", 181 | "Adding 2 to the list.\n", 182 | "Adding 3 to the list.\n", 183 | "Adding 4 to the list.\n", 184 | "Adding 5 to the list.\n", 185 | "Element was: 0\n", 186 | "Element was: 1\n", 187 | "Element was: 2\n", 188 | "Element was: 3\n", 189 | "Element was: 4\n", 190 | "Element was: 5\n" 191 | ] 192 | } 193 | ], 194 | "source": [ 195 | "the_count = [1, 2, 3, 4, 5]\n", 196 | "fruits = ['apples', 'oranges', 'pears', 'apricots']\n", 197 | "change = [1, 'pennies', 2, 'dimes', 3, 'quarters']\n", 198 | "\n", 199 | "# this first kind of for-loop goes through a list\n", 200 | "for number in the_count:\n", 201 | " print(f\"This is count {number}\")\n", 202 | "\n", 203 | "# same as above\n", 204 | "for fruit in fruits:\n", 205 | " print(f\"A fruit of type: {fruit}\")\n", 206 | "\n", 207 | "# also we can go through mixed lists too\n", 208 | "# notice we have to use %r since we don't know what's in items\n", 209 | "for i in change:\n", 210 | " print(f\"I got {i}\")\n", 211 | "\n", 212 | "# we can also build lists, first start with an empty one\n", 213 | "elements = []\n", 214 | "\n", 215 | "# then use the range function to do 0 to 5 counts\n", 216 | "for i in range(0, 6):\n", 217 | " print(f\"Adding {i} to the list.\")\n", 218 | " # append is a function that lists understand\n", 219 | " elements.append(i)\n", 220 | "\n", 221 | "# now we can print them out too\n", 222 | "for i in elements:\n", 223 | " print(f\"Element was: {i}\")" 224 | ] 225 | }, 226 | { 227 | "cell_type": "code", 228 | "execution_count": 19, 229 | "metadata": {}, 230 | "outputs": [ 231 | { 232 | "name": "stdout", 233 | "output_type": "stream", 234 | "text": [ 235 | "This is count 1\n", 236 | "This is count 2\n", 237 | "This is count 3\n" 238 | ] 239 | } 240 | ], 241 | "source": [ 242 | "the_count = [1, 2, 3]\n", 243 | "\n", 244 | "# this first kind of for-loop goes through a list\n", 245 | "for number in the_count:\n", 246 | " print(f\"This is count {number}\")" 247 | ] 248 | }, 249 | { 250 | "cell_type": "code", 251 | "execution_count": null, 252 | "metadata": {}, 253 | "outputs": [], 254 | "source": [] 255 | }, 256 | { 257 | "cell_type": "code", 258 | "execution_count": 20, 259 | "metadata": {}, 260 | "outputs": [ 261 | { 262 | "name": "stdout", 263 | "output_type": "stream", 264 | "text": [ 265 | "This is count 1\n", 266 | "This is count 2\n", 267 | "This is count 3\n" 268 | ] 269 | } 270 | ], 271 | "source": [ 272 | "number =1\n", 273 | "print(f\"This is count {number}\")\n", 274 | "number =2\n", 275 | "print(f\"This is count {number}\")\n", 276 | "number =3\n", 277 | "print(f\"This is count {number}\")" 278 | ] 279 | }, 280 | { 281 | "cell_type": "code", 282 | "execution_count": 30, 283 | "metadata": {}, 284 | "outputs": [ 285 | { 286 | "name": "stdout", 287 | "output_type": "stream", 288 | "text": [ 289 | "[0]\n", 290 | "[0, 1]\n", 291 | "[0, 1, 2]\n", 292 | "[0, 1, 2, 3]\n", 293 | "[0, 1, 2, 3, 4]\n", 294 | "[0, 1, 2, 3, 4, 5]\n" 295 | ] 296 | } 297 | ], 298 | "source": [ 299 | "element = []\n", 300 | "for i in range(0, 6):\n", 301 | " #print(f\"Adding {i} to the list.\")\n", 302 | " # append is a function that lists understand\n", 303 | " element.append(i)\n", 304 | " print(element)" 305 | ] 306 | }, 307 | { 308 | "cell_type": "code", 309 | "execution_count": 33, 310 | "metadata": {}, 311 | "outputs": [ 312 | { 313 | "name": "stdout", 314 | "output_type": "stream", 315 | "text": [ 316 | "At the top i is 0\n", 317 | "Numbers now: [0]\n", 318 | "At the bottom i is 1\n", 319 | "At the top i is 1\n", 320 | "Numbers now: [0, 1]\n", 321 | "At the bottom i is 2\n", 322 | "At the top i is 2\n", 323 | "Numbers now: [0, 1, 2]\n", 324 | "At the bottom i is 3\n", 325 | "At the top i is 3\n", 326 | "Numbers now: [0, 1, 2, 3]\n", 327 | "At the bottom i is 4\n", 328 | "At the top i is 4\n", 329 | "Numbers now: [0, 1, 2, 3, 4]\n", 330 | "At the bottom i is 5\n", 331 | "At the top i is 5\n", 332 | "Numbers now: [0, 1, 2, 3, 4, 5]\n", 333 | "At the bottom i is 6\n", 334 | "The numbers: \n", 335 | "0\n", 336 | "1\n", 337 | "2\n", 338 | "3\n", 339 | "4\n", 340 | "5\n" 341 | ] 342 | } 343 | ], 344 | "source": [ 345 | "i = 0\n", 346 | "numbers = []\n", 347 | "\n", 348 | "while i < 6:\n", 349 | " print(f\"At the top i is {i}\")\n", 350 | " numbers.append(i)\n", 351 | "\n", 352 | " i = i + 1\n", 353 | " print(\"Numbers now: \", numbers)\n", 354 | " print(f\"At the bottom i is {i}\")\n", 355 | "\n", 356 | "print(\"The numbers: \")\n", 357 | "\n", 358 | "for num in numbers:\n", 359 | " print(num)" 360 | ] 361 | }, 362 | { 363 | "cell_type": "code", 364 | "execution_count": 32, 365 | "metadata": {}, 366 | "outputs": [ 367 | { 368 | "name": "stdout", 369 | "output_type": "stream", 370 | "text": [ 371 | "1\n", 372 | "2\n", 373 | "3\n", 374 | "4\n", 375 | "5\n", 376 | "6\n" 377 | ] 378 | } 379 | ], 380 | "source": [ 381 | "i = 0\n", 382 | "numbers = []\n", 383 | "\n", 384 | "while i < 6:\n", 385 | " i=i+1\n", 386 | " print(i)\n", 387 | " " 388 | ] 389 | }, 390 | { 391 | "cell_type": "code", 392 | "execution_count": null, 393 | "metadata": {}, 394 | "outputs": [], 395 | "source": [] 396 | } 397 | ], 398 | "metadata": { 399 | "kernelspec": { 400 | "display_name": "Python 3.6", 401 | "language": "python", 402 | "name": "python36" 403 | }, 404 | "language_info": { 405 | "codemirror_mode": { 406 | "name": "ipython", 407 | "version": 3 408 | }, 409 | "file_extension": ".py", 410 | "mimetype": "text/x-python", 411 | "name": "python", 412 | "nbconvert_exporter": "python", 413 | "pygments_lexer": "ipython3", 414 | "version": "3.6.3" 415 | } 416 | }, 417 | "nbformat": 4, 418 | "nbformat_minor": 2 419 | } 420 | -------------------------------------------------------------------------------- /june/part2june17.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 21, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "data": { 10 | "text/html": [ 11 | "
\n", 12 | "\n", 25 | "\n", 26 | " \n", 27 | " \n", 28 | " \n", 29 | " \n", 30 | " \n", 31 | " \n", 32 | " \n", 33 | " \n", 34 | " \n", 35 | " \n", 36 | " \n", 37 | " \n", 38 | " \n", 39 | " \n", 40 | " \n", 41 | " \n", 42 | " \n", 43 | " \n", 44 | " \n", 45 | " \n", 46 | " \n", 47 | " \n", 48 | " \n", 49 | " \n", 50 | " \n", 51 | " \n", 52 | " \n", 53 | " \n", 54 | " \n", 55 | " \n", 56 | " \n", 57 | " \n", 58 | " \n", 59 | " \n", 60 | " \n", 61 | " \n", 62 | " \n", 63 | " \n", 64 | " \n", 65 | " \n", 66 | " \n", 67 | " \n", 68 | " \n", 69 | " \n", 70 | " \n", 71 | " \n", 72 | " \n", 73 | " \n", 74 | " \n", 75 | "
NameCityAgeSalaryGenderDistance
0AM3212312M10
1BB34231231F14
2CQ54321321F32
3DM4332131M21
\n", 76 | "
" 77 | ], 78 | "text/plain": [ 79 | " Name City Age Salary Gender Distance\n", 80 | "0 A M 32 12312 M 10\n", 81 | "1 B B 34 231231 F 14\n", 82 | "2 C Q 54 321321 F 32\n", 83 | "3 D M 43 32131 M 21" 84 | ] 85 | }, 86 | "execution_count": 21, 87 | "metadata": {}, 88 | "output_type": "execute_result" 89 | } 90 | ], 91 | "source": [ 92 | "import pandas as pd\n", 93 | "df17 = pd.read_csv('http://blockchainainyc.com/wp-content/uploads/2018/06/pandas17june.csv')\n", 94 | "df17" 95 | ] 96 | }, 97 | { 98 | "cell_type": "code", 99 | "execution_count": 25, 100 | "metadata": {}, 101 | "outputs": [ 102 | { 103 | "data": { 104 | "text/html": [ 105 | "
\n", 106 | "\n", 119 | "\n", 120 | " \n", 121 | " \n", 122 | " \n", 123 | " \n", 124 | " \n", 125 | " \n", 126 | " \n", 127 | " \n", 128 | " \n", 129 | " \n", 130 | " \n", 131 | " \n", 132 | " \n", 133 | " \n", 134 | " \n", 135 | " \n", 136 | " \n", 137 | " \n", 138 | " \n", 139 | " \n", 140 | " \n", 141 | " \n", 142 | " \n", 143 | " \n", 144 | " \n", 145 | " \n", 146 | " \n", 147 | " \n", 148 | " \n", 149 | " \n", 150 | " \n", 151 | "
NameCityAgeSalaryGenderDistance
0AM3212312M10
3DM4332131M21
\n", 152 | "
" 153 | ], 154 | "text/plain": [ 155 | " Name City Age Salary Gender Distance\n", 156 | "0 A M 32 12312 M 10\n", 157 | "3 D M 43 32131 M 21" 158 | ] 159 | }, 160 | "execution_count": 25, 161 | "metadata": {}, 162 | "output_type": "execute_result" 163 | } 164 | ], 165 | "source": [ 166 | "df17[df17['City']=='M']" 167 | ] 168 | }, 169 | { 170 | "cell_type": "code", 171 | "execution_count": 39, 172 | "metadata": {}, 173 | "outputs": [ 174 | { 175 | "data": { 176 | "text/html": [ 177 | "
\n", 178 | "\n", 191 | "\n", 192 | " \n", 193 | " \n", 194 | " \n", 195 | " \n", 196 | " \n", 197 | " \n", 198 | " \n", 199 | " \n", 200 | " \n", 201 | " \n", 202 | " \n", 203 | " \n", 204 | " \n", 205 | " \n", 206 | " \n", 207 | " \n", 208 | " \n", 209 | " \n", 210 | " \n", 211 | " \n", 212 | " \n", 213 | " \n", 214 | "
NameCityAgeSalaryGenderDistance
3DM4332131M21
\n", 215 | "
" 216 | ], 217 | "text/plain": [ 218 | " Name City Age Salary Gender Distance\n", 219 | "3 D M 43 32131 M 21" 220 | ] 221 | }, 222 | "execution_count": 39, 223 | "metadata": {}, 224 | "output_type": "execute_result" 225 | } 226 | ], 227 | "source": [ 228 | "df17[(df17['City']=='M') & (df17['Age']>35)]" 229 | ] 230 | }, 231 | { 232 | "cell_type": "code", 233 | "execution_count": 33, 234 | "metadata": {}, 235 | "outputs": [ 236 | { 237 | "data": { 238 | "text/plain": [ 239 | "0 False\n", 240 | "1 False\n", 241 | "2 True\n", 242 | "3 True\n", 243 | "Name: Age, dtype: bool" 244 | ] 245 | }, 246 | "execution_count": 33, 247 | "metadata": {}, 248 | "output_type": "execute_result" 249 | } 250 | ], 251 | "source": [] 252 | }, 253 | { 254 | "cell_type": "code", 255 | "execution_count": 31, 256 | "metadata": {}, 257 | "outputs": [ 258 | { 259 | "data": { 260 | "text/html": [ 261 | "
\n", 262 | "\n", 275 | "\n", 276 | " \n", 277 | " \n", 278 | " \n", 279 | " \n", 280 | " \n", 281 | " \n", 282 | " \n", 283 | " \n", 284 | " \n", 285 | " \n", 286 | " \n", 287 | " \n", 288 | " \n", 289 | " \n", 290 | " \n", 291 | " \n", 292 | " \n", 293 | " \n", 294 | " \n", 295 | " \n", 296 | " \n", 297 | " \n", 298 | " \n", 299 | " \n", 300 | " \n", 301 | " \n", 302 | " \n", 303 | " \n", 304 | " \n", 305 | " \n", 306 | " \n", 307 | "
NameCityAgeSalaryGenderDistance
0AM3212312M10
3DM4332131M21
\n", 308 | "
" 309 | ], 310 | "text/plain": [ 311 | " Name City Age Salary Gender Distance\n", 312 | "0 A M 32 12312 M 10\n", 313 | "3 D M 43 32131 M 21" 314 | ] 315 | }, 316 | "execution_count": 31, 317 | "metadata": {}, 318 | "output_type": "execute_result" 319 | } 320 | ], 321 | "source": [ 322 | "df17[df17['City']==\"M\"]" 323 | ] 324 | }, 325 | { 326 | "cell_type": "code", 327 | "execution_count": 7, 328 | "metadata": {}, 329 | "outputs": [ 330 | { 331 | "data": { 332 | "text/plain": [ 333 | "Name object\n", 334 | "City object\n", 335 | "Age int64\n", 336 | "Salary int64\n", 337 | "Gender object\n", 338 | "Distance int64\n", 339 | "dtype: object" 340 | ] 341 | }, 342 | "execution_count": 7, 343 | "metadata": {}, 344 | "output_type": "execute_result" 345 | } 346 | ], 347 | "source": [ 348 | "df17.dtypes" 349 | ] 350 | }, 351 | { 352 | "cell_type": "code", 353 | "execution_count": 40, 354 | "metadata": {}, 355 | "outputs": [ 356 | { 357 | "data": { 358 | "text/html": [ 359 | "
\n", 360 | "\n", 373 | "\n", 374 | " \n", 375 | " \n", 376 | " \n", 377 | " \n", 378 | " \n", 379 | " \n", 380 | " \n", 381 | " \n", 382 | " \n", 383 | " \n", 384 | " \n", 385 | " \n", 386 | " \n", 387 | " \n", 388 | " \n", 389 | " \n", 390 | " \n", 391 | " \n", 392 | " \n", 393 | " \n", 394 | " \n", 395 | " \n", 396 | "
NameCityAgeSalaryGenderDistance
3DM4332131M21
\n", 397 | "
" 398 | ], 399 | "text/plain": [ 400 | " Name City Age Salary Gender Distance\n", 401 | "3 D M 43 32131 M 21" 402 | ] 403 | }, 404 | "execution_count": 40, 405 | "metadata": {}, 406 | "output_type": "execute_result" 407 | } 408 | ], 409 | "source": [ 410 | "df17[(df17['Gender']=='M') & (df17['Age']>35)]" 411 | ] 412 | }, 413 | { 414 | "cell_type": "code", 415 | "execution_count": 45, 416 | "metadata": {}, 417 | "outputs": [ 418 | { 419 | "data": { 420 | "text/plain": [ 421 | "City\n", 422 | "B 1\n", 423 | "M 2\n", 424 | "Q 1\n", 425 | "Name: City, dtype: int64" 426 | ] 427 | }, 428 | "execution_count": 45, 429 | "metadata": {}, 430 | "output_type": "execute_result" 431 | } 432 | ], 433 | "source": [ 434 | "df17.groupby(['City'])['City'].count()" 435 | ] 436 | }, 437 | { 438 | "cell_type": "code", 439 | "execution_count": 46, 440 | "metadata": {}, 441 | "outputs": [ 442 | { 443 | "data": { 444 | "text/html": [ 445 | "
\n", 446 | "\n", 459 | "\n", 460 | " \n", 461 | " \n", 462 | " \n", 463 | " \n", 464 | " \n", 465 | " \n", 466 | " \n", 467 | " \n", 468 | " \n", 469 | " \n", 470 | " \n", 471 | " \n", 472 | " \n", 473 | " \n", 474 | " \n", 475 | " \n", 476 | " \n", 477 | " \n", 478 | " \n", 479 | " \n", 480 | " \n", 481 | " \n", 482 | " \n", 483 | " \n", 484 | " \n", 485 | " \n", 486 | " \n", 487 | " \n", 488 | " \n", 489 | " \n", 490 | " \n", 491 | " \n", 492 | " \n", 493 | " \n", 494 | " \n", 495 | " \n", 496 | " \n", 497 | " \n", 498 | " \n", 499 | " \n", 500 | " \n", 501 | " \n", 502 | " \n", 503 | " \n", 504 | " \n", 505 | " \n", 506 | " \n", 507 | " \n", 508 | " \n", 509 | "
NameCityAgeSalaryGenderDistance
0AM3212312M10
1BB34231231F14
2CQ54321321F32
3DM4332131M21
\n", 510 | "
" 511 | ], 512 | "text/plain": [ 513 | " Name City Age Salary Gender Distance\n", 514 | "0 A M 32 12312 M 10\n", 515 | "1 B B 34 231231 F 14\n", 516 | "2 C Q 54 321321 F 32\n", 517 | "3 D M 43 32131 M 21" 518 | ] 519 | }, 520 | "execution_count": 46, 521 | "metadata": {}, 522 | "output_type": "execute_result" 523 | } 524 | ], 525 | "source": [ 526 | "df17" 527 | ] 528 | }, 529 | { 530 | "cell_type": "code", 531 | "execution_count": 52, 532 | "metadata": {}, 533 | "outputs": [ 534 | { 535 | "data": { 536 | "text/html": [ 537 | "
\n", 538 | "\n", 551 | "\n", 552 | " \n", 553 | " \n", 554 | " \n", 555 | " \n", 556 | " \n", 557 | " \n", 558 | " \n", 559 | " \n", 560 | " \n", 561 | " \n", 562 | " \n", 563 | " \n", 564 | " \n", 565 | " \n", 566 | " \n", 567 | " \n", 568 | " \n", 569 | " \n", 570 | " \n", 571 | " \n", 572 | " \n", 573 | " \n", 574 | " \n", 575 | " \n", 576 | " \n", 577 | " \n", 578 | " \n", 579 | " \n", 580 | " \n", 581 | " \n", 582 | " \n", 583 | " \n", 584 | " \n", 585 | " \n", 586 | " \n", 587 | " \n", 588 | " \n", 589 | " \n", 590 | " \n", 591 | " \n", 592 | "
NameCityAgeSalaryGenderDistance
1BB34231231F14
2CQ54321321F32
3DM4332131M21
\n", 593 | "
" 594 | ], 595 | "text/plain": [ 596 | " Name City Age Salary Gender Distance\n", 597 | "1 B B 34 231231 F 14\n", 598 | "2 C Q 54 321321 F 32\n", 599 | "3 D M 43 32131 M 21" 600 | ] 601 | }, 602 | "execution_count": 52, 603 | "metadata": {}, 604 | "output_type": "execute_result" 605 | } 606 | ], 607 | "source": [ 608 | "df17.iloc[1:,:]" 609 | ] 610 | }, 611 | { 612 | "cell_type": "code", 613 | "execution_count": 53, 614 | "metadata": {}, 615 | "outputs": [ 616 | { 617 | "data": { 618 | "text/html": [ 619 | "
\n", 620 | "\n", 633 | "\n", 634 | " \n", 635 | " \n", 636 | " \n", 637 | " \n", 638 | " \n", 639 | " \n", 640 | " \n", 641 | " \n", 642 | " \n", 643 | " \n", 644 | " \n", 645 | " \n", 646 | " \n", 647 | " \n", 648 | " \n", 649 | " \n", 650 | " \n", 651 | " \n", 652 | " \n", 653 | " \n", 654 | " \n", 655 | " \n", 656 | " \n", 657 | " \n", 658 | " \n", 659 | " \n", 660 | " \n", 661 | " \n", 662 | " \n", 663 | " \n", 664 | " \n", 665 | " \n", 666 | " \n", 667 | " \n", 668 | " \n", 669 | " \n", 670 | " \n", 671 | " \n", 672 | " \n", 673 | " \n", 674 | " \n", 675 | " \n", 676 | " \n", 677 | " \n", 678 | " \n", 679 | " \n", 680 | " \n", 681 | " \n", 682 | " \n", 683 | "
NameCityAgeSalaryGenderDistance
0AM3212312M10
1BB34231231F14
2CQ54321321F32
3DM4332131M21
\n", 684 | "
" 685 | ], 686 | "text/plain": [ 687 | " Name City Age Salary Gender Distance\n", 688 | "0 A M 32 12312 M 10\n", 689 | "1 B B 34 231231 F 14\n", 690 | "2 C Q 54 321321 F 32\n", 691 | "3 D M 43 32131 M 21" 692 | ] 693 | }, 694 | "execution_count": 53, 695 | "metadata": {}, 696 | "output_type": "execute_result" 697 | } 698 | ], 699 | "source": [ 700 | "df17" 701 | ] 702 | }, 703 | { 704 | "cell_type": "code", 705 | "execution_count": 55, 706 | "metadata": {}, 707 | "outputs": [ 708 | { 709 | "data": { 710 | "text/html": [ 711 | "
\n", 712 | "\n", 725 | "\n", 726 | " \n", 727 | " \n", 728 | " \n", 729 | " \n", 730 | " \n", 731 | " \n", 732 | " \n", 733 | " \n", 734 | " \n", 735 | " \n", 736 | " \n", 737 | " \n", 738 | " \n", 739 | " \n", 740 | " \n", 741 | " \n", 742 | "
City
0M
1B
\n", 743 | "
" 744 | ], 745 | "text/plain": [ 746 | " City\n", 747 | "0 M\n", 748 | "1 B" 749 | ] 750 | }, 751 | "execution_count": 55, 752 | "metadata": {}, 753 | "output_type": "execute_result" 754 | } 755 | ], 756 | "source": [ 757 | "df17.iloc[:2,1:2]" 758 | ] 759 | }, 760 | { 761 | "cell_type": "code", 762 | "execution_count": null, 763 | "metadata": {}, 764 | "outputs": [], 765 | "source": [] 766 | }, 767 | { 768 | "cell_type": "code", 769 | "execution_count": 57, 770 | "metadata": {}, 771 | "outputs": [ 772 | { 773 | "data": { 774 | "text/html": [ 775 | "
\n", 776 | "\n", 789 | "\n", 790 | " \n", 791 | " \n", 792 | " \n", 793 | " \n", 794 | " \n", 795 | " \n", 796 | " \n", 797 | " \n", 798 | " \n", 799 | " \n", 800 | " \n", 801 | " \n", 802 | " \n", 803 | " \n", 804 | " \n", 805 | " \n", 806 | " \n", 807 | " \n", 808 | " \n", 809 | " \n", 810 | " \n", 811 | " \n", 812 | " \n", 813 | " \n", 814 | " \n", 815 | " \n", 816 | " \n", 817 | " \n", 818 | " \n", 819 | " \n", 820 | " \n", 821 | " \n", 822 | " \n", 823 | " \n", 824 | " \n", 825 | " \n", 826 | " \n", 827 | " \n", 828 | " \n", 829 | " \n", 830 | " \n", 831 | " \n", 832 | " \n", 833 | " \n", 834 | " \n", 835 | " \n", 836 | " \n", 837 | " \n", 838 | " \n", 839 | "
NameCityAgeSalaryGenderDistance
0EM4312312M54
1FB43231231F32
2GQ43321321F32
3HC4332131M32
\n", 840 | "
" 841 | ], 842 | "text/plain": [ 843 | " Name City Age Salary Gender Distance\n", 844 | "0 E M 43 12312 M 54\n", 845 | "1 F B 43 231231 F 32\n", 846 | "2 G Q 43 321321 F 32\n", 847 | "3 H C 43 32131 M 32" 848 | ] 849 | }, 850 | "execution_count": 57, 851 | "metadata": {}, 852 | "output_type": "execute_result" 853 | } 854 | ], 855 | "source": [ 856 | "df19 = pd.read_csv('http://blockchainainyc.com/wp-content/uploads/2018/06/newdata.csv')\n", 857 | "df19" 858 | ] 859 | }, 860 | { 861 | "cell_type": "code", 862 | "execution_count": 59, 863 | "metadata": {}, 864 | "outputs": [ 865 | { 866 | "data": { 867 | "text/html": [ 868 | "
\n", 869 | "\n", 882 | "\n", 883 | " \n", 884 | " \n", 885 | " \n", 886 | " \n", 887 | " \n", 888 | " \n", 889 | " \n", 890 | " \n", 891 | " \n", 892 | " \n", 893 | " \n", 894 | " \n", 895 | " \n", 896 | " \n", 897 | " \n", 898 | " \n", 899 | " \n", 900 | " \n", 901 | " \n", 902 | " \n", 903 | " \n", 904 | " \n", 905 | " \n", 906 | " \n", 907 | " \n", 908 | " \n", 909 | " \n", 910 | " \n", 911 | " \n", 912 | " \n", 913 | " \n", 914 | " \n", 915 | " \n", 916 | " \n", 917 | " \n", 918 | " \n", 919 | " \n", 920 | " \n", 921 | " \n", 922 | " \n", 923 | " \n", 924 | " \n", 925 | " \n", 926 | " \n", 927 | " \n", 928 | " \n", 929 | " \n", 930 | " \n", 931 | " \n", 932 | " \n", 933 | " \n", 934 | " \n", 935 | " \n", 936 | " \n", 937 | " \n", 938 | " \n", 939 | " \n", 940 | " \n", 941 | " \n", 942 | " \n", 943 | " \n", 944 | " \n", 945 | " \n", 946 | " \n", 947 | " \n", 948 | " \n", 949 | " \n", 950 | " \n", 951 | " \n", 952 | " \n", 953 | " \n", 954 | " \n", 955 | " \n", 956 | " \n", 957 | " \n", 958 | " \n", 959 | " \n", 960 | " \n", 961 | " \n", 962 | " \n", 963 | " \n", 964 | " \n", 965 | " \n", 966 | " \n", 967 | " \n", 968 | "
NameCityAgeSalaryGenderDistance
0AM3212312M10
1BB34231231F14
2CQ54321321F32
3DM4332131M21
0EM4312312M54
1FB43231231F32
2GQ43321321F32
3HC4332131M32
\n", 969 | "
" 970 | ], 971 | "text/plain": [ 972 | " Name City Age Salary Gender Distance\n", 973 | "0 A M 32 12312 M 10\n", 974 | "1 B B 34 231231 F 14\n", 975 | "2 C Q 54 321321 F 32\n", 976 | "3 D M 43 32131 M 21\n", 977 | "0 E M 43 12312 M 54\n", 978 | "1 F B 43 231231 F 32\n", 979 | "2 G Q 43 321321 F 32\n", 980 | "3 H C 43 32131 M 32" 981 | ] 982 | }, 983 | "execution_count": 59, 984 | "metadata": {}, 985 | "output_type": "execute_result" 986 | } 987 | ], 988 | "source": [ 989 | "pd.concat([df17,df19])" 990 | ] 991 | }, 992 | { 993 | "cell_type": "code", 994 | "execution_count": null, 995 | "metadata": {}, 996 | "outputs": [], 997 | "source": [] 998 | } 999 | ], 1000 | "metadata": { 1001 | "kernelspec": { 1002 | "display_name": "Python 3.6", 1003 | "language": "python", 1004 | "name": "python36" 1005 | }, 1006 | "language_info": { 1007 | "codemirror_mode": { 1008 | "name": "ipython", 1009 | "version": 3 1010 | }, 1011 | "file_extension": ".py", 1012 | "mimetype": "text/x-python", 1013 | "name": "python", 1014 | "nbconvert_exporter": "python", 1015 | "pygments_lexer": "ipython3", 1016 | "version": "3.6.3" 1017 | } 1018 | }, 1019 | "nbformat": 4, 1020 | "nbformat_minor": 2 1021 | } 1022 | -------------------------------------------------------------------------------- /nullplay.txt: -------------------------------------------------------------------------------- 1 | A,B 2 | ,1 3 | 2, -------------------------------------------------------------------------------- /pda ch3.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "data": { 10 | "text/plain": [ 11 | "['BAT', 'CAR', 'DOVE', 'PYTHON']" 12 | ] 13 | }, 14 | "execution_count": 1, 15 | "metadata": {}, 16 | "output_type": "execute_result" 17 | } 18 | ], 19 | "source": [ 20 | "\n", 21 | "strings = ['a', 'as', 'bat', 'car', 'dove', 'python']\n", 22 | "[x.upper() for x in strings if len(x) > 2]" 23 | ] 24 | }, 25 | { 26 | "cell_type": "code", 27 | "execution_count": 4, 28 | "metadata": {}, 29 | "outputs": [ 30 | { 31 | "data": { 32 | "text/plain": [ 33 | "['BAT', 'CAR', 'DOVE', 'PYTHON']" 34 | ] 35 | }, 36 | "execution_count": 4, 37 | "metadata": {}, 38 | "output_type": "execute_result" 39 | } 40 | ], 41 | "source": [ 42 | "newlist =[]\n", 43 | "for x in strings:\n", 44 | " if len(x) > 2:\n", 45 | " newlist.append(x.upper())\n", 46 | " \n", 47 | "newlist\n", 48 | "\n" 49 | ] 50 | }, 51 | { 52 | "cell_type": "code", 53 | "execution_count": 6, 54 | "metadata": {}, 55 | "outputs": [ 56 | { 57 | "data": { 58 | "text/plain": [ 59 | "set" 60 | ] 61 | }, 62 | "execution_count": 6, 63 | "metadata": {}, 64 | "output_type": "execute_result" 65 | } 66 | ], 67 | "source": [ 68 | "\n", 69 | "unique_lengths = {len(x) for x in strings}\n", 70 | "type(unique_lengths)" 71 | ] 72 | }, 73 | { 74 | "cell_type": "code", 75 | "execution_count": 7, 76 | "metadata": {}, 77 | "outputs": [ 78 | { 79 | "data": { 80 | "text/plain": [ 81 | "{1, 2, 3, 4, 6}" 82 | ] 83 | }, 84 | "execution_count": 7, 85 | "metadata": {}, 86 | "output_type": "execute_result" 87 | } 88 | ], 89 | "source": [ 90 | "unique_lengths" 91 | ] 92 | }, 93 | { 94 | "cell_type": "code", 95 | "execution_count": 9, 96 | "metadata": { 97 | "collapsed": true 98 | }, 99 | "outputs": [], 100 | "source": [ 101 | "pythonclasstoday = {'J', 'T', 'S', 'E', 'R'}\n", 102 | "pythontutorsalltime ={'J', 'T', 'Rm'}\n", 103 | "pythonclasstoday & pythontutorsalltime" 104 | ] 105 | }, 106 | { 107 | "cell_type": "code", 108 | "execution_count": 13, 109 | "metadata": {}, 110 | "outputs": [ 111 | { 112 | "data": { 113 | "text/plain": [ 114 | "{1, 2, 3, 4, 6}" 115 | ] 116 | }, 117 | "execution_count": 13, 118 | "metadata": {}, 119 | "output_type": "execute_result" 120 | } 121 | ], 122 | "source": [ 123 | "set(map(len, strings))\n" 124 | ] 125 | }, 126 | { 127 | "cell_type": "code", 128 | "execution_count": 11, 129 | "metadata": {}, 130 | "outputs": [ 131 | { 132 | "data": { 133 | "text/plain": [ 134 | "{'J', 'T'}" 135 | ] 136 | }, 137 | "execution_count": 11, 138 | "metadata": {}, 139 | "output_type": "execute_result" 140 | } 141 | ], 142 | "source": [] 143 | }, 144 | { 145 | "cell_type": "code", 146 | "execution_count": 15, 147 | "metadata": {}, 148 | "outputs": [ 149 | { 150 | "data": { 151 | "text/plain": [ 152 | "[1, 2, 3, 3, 4, 6]" 153 | ] 154 | }, 155 | "execution_count": 15, 156 | "metadata": {}, 157 | "output_type": "execute_result" 158 | } 159 | ], 160 | "source": [ 161 | "unique_lengths = {len(x) for x in strings}\n", 162 | "\n", 163 | "set(map(len, strings))" 164 | ] 165 | }, 166 | { 167 | "cell_type": "code", 168 | "execution_count": 16, 169 | "metadata": {}, 170 | "outputs": [ 171 | { 172 | "data": { 173 | "text/plain": [ 174 | "{'a': 0, 'as': 1, 'bat': 2, 'car': 3, 'dove': 4, 'python': 5}" 175 | ] 176 | }, 177 | "execution_count": 16, 178 | "metadata": {}, 179 | "output_type": "execute_result" 180 | } 181 | ], 182 | "source": [ 183 | "\n", 184 | "loc_mapping = {val : index for index, val in enumerate(strings)}\n", 185 | "loc_mapping" 186 | ] 187 | }, 188 | { 189 | "cell_type": "code", 190 | "execution_count": 19, 191 | "metadata": {}, 192 | "outputs": [ 193 | { 194 | "name": "stdout", 195 | "output_type": "stream", 196 | "text": [ 197 | "[]\n" 198 | ] 199 | } 200 | ], 201 | "source": [ 202 | "a = None\n", 203 | "def bind_a_variable():\n", 204 | " global a\n", 205 | " a = []\n", 206 | "bind_a_variable()\n", 207 | "print(a)" 208 | ] 209 | }, 210 | { 211 | "cell_type": "code", 212 | "execution_count": 20, 213 | "metadata": { 214 | "collapsed": true 215 | }, 216 | "outputs": [], 217 | "source": [] 218 | }, 219 | { 220 | "cell_type": "code", 221 | "execution_count": 21, 222 | "metadata": {}, 223 | "outputs": [ 224 | { 225 | "data": { 226 | "text/plain": [ 227 | "['Alabama',\n", 228 | " 'Georgia',\n", 229 | " 'Georgia',\n", 230 | " 'Georgia',\n", 231 | " 'Florida',\n", 232 | " 'South Carolina',\n", 233 | " 'West Virginia']" 234 | ] 235 | }, 236 | "execution_count": 21, 237 | "metadata": {}, 238 | "output_type": "execute_result" 239 | } 240 | ], 241 | "source": [ 242 | "states = [' Alabama ', 'Georgia!', 'Georgia', 'georgia', 'FlOrIda',\n", 243 | " 'south carolina##', 'West virginia?']\n", 244 | "import re\n", 245 | "\n", 246 | "def clean_strings(strings):\n", 247 | " result = []\n", 248 | " for value in strings:\n", 249 | " value = value.strip()\n", 250 | " value = re.sub('[!#?]', '', value)\n", 251 | " value = value.title()\n", 252 | " result.append(value)\n", 253 | " return result\n", 254 | "clean_strings(states)\n" 255 | ] 256 | }, 257 | { 258 | "cell_type": "code", 259 | "execution_count": 22, 260 | "metadata": { 261 | "collapsed": true 262 | }, 263 | "outputs": [], 264 | "source": [ 265 | "def remove_punctuation(value):\n", 266 | " return re.sub('[!#?]', '', value)\n", 267 | "\n", 268 | "clean_ops = [str.strip, remove_punctuation, str.title]\n", 269 | "\n", 270 | "def clean_strings(strings, ops):\n", 271 | " result = []\n", 272 | " for value in strings:\n", 273 | " for function in ops:\n", 274 | " value = function(value)\n", 275 | " result.append(value)\n", 276 | " return result\n", 277 | "clean_strings(states, clean_ops)" 278 | ] 279 | }, 280 | { 281 | "cell_type": "code", 282 | "execution_count": 27, 283 | "metadata": {}, 284 | "outputs": [ 285 | { 286 | "data": { 287 | "text/plain": [ 288 | "[' Alabama ',\n", 289 | " 'Georgia',\n", 290 | " 'Georgia',\n", 291 | " 'georgia',\n", 292 | " 'FlOrIda',\n", 293 | " 'south carolina',\n", 294 | " 'West virginia']" 295 | ] 296 | }, 297 | "execution_count": 27, 298 | "metadata": {}, 299 | "output_type": "execute_result" 300 | } 301 | ], 302 | "source": [ 303 | "\n", 304 | "\n", 305 | "list(map(remove_punctuation, states))\n" 306 | ] 307 | }, 308 | { 309 | "cell_type": "code", 310 | "execution_count": 30, 311 | "metadata": {}, 312 | "outputs": [ 313 | { 314 | "data": { 315 | "text/plain": [ 316 | "['aaaa', 'foo', 'abab', 'bar', 'card']" 317 | ] 318 | }, 319 | "execution_count": 30, 320 | "metadata": {}, 321 | "output_type": "execute_result" 322 | } 323 | ], 324 | "source": [ 325 | "strings = ['foo', 'card', 'bar', 'aaaa', 'abab']\n" 326 | ] 327 | }, 328 | { 329 | "cell_type": "code", 330 | "execution_count": 32, 331 | "metadata": {}, 332 | "outputs": [ 333 | { 334 | "data": { 335 | "text/plain": [ 336 | "['aaaa', 'foo', 'abab', 'bar', 'card']" 337 | ] 338 | }, 339 | "execution_count": 32, 340 | "metadata": {}, 341 | "output_type": "execute_result" 342 | } 343 | ], 344 | "source": [ 345 | "strings.sort(key=lambda x: len(set(list(x))))\n", 346 | "strings" 347 | ] 348 | }, 349 | { 350 | "cell_type": "code", 351 | "execution_count": 38, 352 | "metadata": {}, 353 | "outputs": [ 354 | { 355 | "data": { 356 | "text/plain": [ 357 | "['a', 'a', 'a', 'a']" 358 | ] 359 | }, 360 | "execution_count": 38, 361 | "metadata": {}, 362 | "output_type": "execute_result" 363 | } 364 | ], 365 | "source": [ 366 | "x = list('aaaa')\n", 367 | "x" 368 | ] 369 | }, 370 | { 371 | "cell_type": "code", 372 | "execution_count": 39, 373 | "metadata": {}, 374 | "outputs": [ 375 | { 376 | "data": { 377 | "text/plain": [ 378 | "{'a'}" 379 | ] 380 | }, 381 | "execution_count": 39, 382 | "metadata": {}, 383 | "output_type": "execute_result" 384 | } 385 | ], 386 | "source": [ 387 | "y= set(x)\n", 388 | "y" 389 | ] 390 | }, 391 | { 392 | "cell_type": "code", 393 | "execution_count": 40, 394 | "metadata": {}, 395 | "outputs": [ 396 | { 397 | "data": { 398 | "text/plain": [ 399 | "1" 400 | ] 401 | }, 402 | "execution_count": 40, 403 | "metadata": {}, 404 | "output_type": "execute_result" 405 | } 406 | ], 407 | "source": [ 408 | "z= len(y)\n", 409 | "z" 410 | ] 411 | }, 412 | { 413 | "cell_type": "code", 414 | "execution_count": 45, 415 | "metadata": {}, 416 | "outputs": [ 417 | { 418 | "data": { 419 | "text/plain": [ 420 | "['aaaa', 'foo', 'abab', 'bar', 'card']" 421 | ] 422 | }, 423 | "execution_count": 45, 424 | "metadata": {}, 425 | "output_type": "execute_result" 426 | } 427 | ], 428 | "source": [ 429 | "def myfun(inputstring):\n", 430 | " return len(set(list(inputstring)))\n", 431 | "strings = ['foo', 'card', 'bar', 'aaaa', 'abab']\n", 432 | "strings.sort(key=myfun)\n", 433 | "strings" 434 | ] 435 | }, 436 | { 437 | "cell_type": "code", 438 | "execution_count": 46, 439 | "metadata": {}, 440 | "outputs": [ 441 | { 442 | "data": { 443 | "text/plain": [ 444 | "1.2345" 445 | ] 446 | }, 447 | "execution_count": 46, 448 | "metadata": {}, 449 | "output_type": "execute_result" 450 | } 451 | ], 452 | "source": [ 453 | "float('1.2345')\n" 454 | ] 455 | }, 456 | { 457 | "cell_type": "code", 458 | "execution_count": 47, 459 | "metadata": {}, 460 | "outputs": [ 461 | { 462 | "ename": "ValueError", 463 | "evalue": "could not convert string to float: 'something'", 464 | "output_type": "error", 465 | "traceback": [ 466 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 467 | "\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)", 468 | "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mfloat\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'something'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", 469 | "\u001b[1;31mValueError\u001b[0m: could not convert string to float: 'something'" 470 | ] 471 | } 472 | ], 473 | "source": [ 474 | "float('something')" 475 | ] 476 | }, 477 | { 478 | "cell_type": "code", 479 | "execution_count": 48, 480 | "metadata": { 481 | "collapsed": true 482 | }, 483 | "outputs": [], 484 | "source": [ 485 | "def attempt_float(x):\n", 486 | " try:\n", 487 | " return float(x)\n", 488 | " except:\n", 489 | " return x" 490 | ] 491 | }, 492 | { 493 | "cell_type": "code", 494 | "execution_count": 49, 495 | "metadata": {}, 496 | "outputs": [ 497 | { 498 | "data": { 499 | "text/plain": [ 500 | "1.2345" 501 | ] 502 | }, 503 | "execution_count": 49, 504 | "metadata": {}, 505 | "output_type": "execute_result" 506 | } 507 | ], 508 | "source": [ 509 | "#------------------------\n", 510 | "attempt_float('1.2345')\n" 511 | ] 512 | }, 513 | { 514 | "cell_type": "code", 515 | "execution_count": 56, 516 | "metadata": {}, 517 | "outputs": [ 518 | { 519 | "data": { 520 | "text/plain": [ 521 | "'something'" 522 | ] 523 | }, 524 | "execution_count": 56, 525 | "metadata": {}, 526 | "output_type": "execute_result" 527 | } 528 | ], 529 | "source": [ 530 | "#-------------------------------\n", 531 | "attempt_float('something')" 532 | ] 533 | }, 534 | { 535 | "cell_type": "code", 536 | "execution_count": 51, 537 | "metadata": {}, 538 | "outputs": [ 539 | { 540 | "ename": "TypeError", 541 | "evalue": "float() argument must be a string or a number, not 'tuple'", 542 | "output_type": "error", 543 | "traceback": [ 544 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 545 | "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", 546 | "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mfloat\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m2\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", 547 | "\u001b[1;31mTypeError\u001b[0m: float() argument must be a string or a number, not 'tuple'" 548 | ] 549 | } 550 | ], 551 | "source": [ 552 | "float((1, 2))\n" 553 | ] 554 | }, 555 | { 556 | "cell_type": "code", 557 | "execution_count": 54, 558 | "metadata": { 559 | "collapsed": true 560 | }, 561 | "outputs": [], 562 | "source": [ 563 | "def attempt_float(x):\n", 564 | " try:\n", 565 | " return float(x)\n", 566 | " except ValueError:\n", 567 | " return x" 568 | ] 569 | }, 570 | { 571 | "cell_type": "code", 572 | "execution_count": 55, 573 | "metadata": {}, 574 | "outputs": [ 575 | { 576 | "ename": "TypeError", 577 | "evalue": "float() argument must be a string or a number, not 'tuple'", 578 | "output_type": "error", 579 | "traceback": [ 580 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 581 | "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", 582 | "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mattempt_float\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m2\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", 583 | "\u001b[1;32m\u001b[0m in \u001b[0;36mattempt_float\u001b[1;34m(x)\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mattempt_float\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2\u001b[0m \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 3\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mfloat\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 4\u001b[0m \u001b[1;32mexcept\u001b[0m \u001b[0mValueError\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 5\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mx\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", 584 | "\u001b[1;31mTypeError\u001b[0m: float() argument must be a string or a number, not 'tuple'" 585 | ] 586 | } 587 | ], 588 | "source": [ 589 | "attempt_float((1, 2))\n" 590 | ] 591 | }, 592 | { 593 | "cell_type": "code", 594 | "execution_count": 57, 595 | "metadata": { 596 | "collapsed": true 597 | }, 598 | "outputs": [], 599 | "source": [ 600 | "def attempt_float(x):\n", 601 | " try:\n", 602 | " return float(x)\n", 603 | " except (TypeError, ValueError):\n", 604 | " return x" 605 | ] 606 | }, 607 | { 608 | "cell_type": "code", 609 | "execution_count": 58, 610 | "metadata": {}, 611 | "outputs": [ 612 | { 613 | "data": { 614 | "text/plain": [ 615 | "(1, 2)" 616 | ] 617 | }, 618 | "execution_count": 58, 619 | "metadata": {}, 620 | "output_type": "execute_result" 621 | } 622 | ], 623 | "source": [ 624 | "attempt_float((1, 2))\n" 625 | ] 626 | }, 627 | { 628 | "cell_type": "code", 629 | "execution_count": 59, 630 | "metadata": {}, 631 | "outputs": [ 632 | { 633 | "ename": "OSError", 634 | "evalue": "[Errno 22] Invalid argument: 'https://raw.githubusercontent.com/wesm/pydata-book/2nd-edition/examples/segismundo.txt'", 635 | "output_type": "error", 636 | "traceback": [ 637 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 638 | "\u001b[1;31mOSError\u001b[0m Traceback (most recent call last)", 639 | "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2\u001b[0m \u001b[0mpath\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34m'https://raw.githubusercontent.com/wesm/pydata-book/2nd-edition/examples/segismundo.txt'\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 3\u001b[1;33m \u001b[0mf\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mopen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mpath\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", 640 | "\u001b[1;31mOSError\u001b[0m: [Errno 22] Invalid argument: 'https://raw.githubusercontent.com/wesm/pydata-book/2nd-edition/examples/segismundo.txt'" 641 | ] 642 | } 643 | ], 644 | "source": [ 645 | "\n", 646 | "path = 'https://raw.githubusercontent.com/wesm/pydata-book/2nd-edition/examples/segismundo.txt'\n", 647 | "f = open(path)" 648 | ] 649 | }, 650 | { 651 | "cell_type": "code", 652 | "execution_count": 60, 653 | "metadata": {}, 654 | "outputs": [ 655 | { 656 | "name": "stdout", 657 | "output_type": "stream", 658 | "text": [ 659 | "/c/Users/xxx.XXX/Documents\n" 660 | ] 661 | } 662 | ], 663 | "source": [ 664 | "!pwd" 665 | ] 666 | }, 667 | { 668 | "cell_type": "code", 669 | "execution_count": 61, 670 | "metadata": { 671 | "collapsed": true 672 | }, 673 | "outputs": [], 674 | "source": [ 675 | "\n", 676 | "import numpy as np\n", 677 | "np.random.seed(12345)\n", 678 | "import matplotlib.pyplot as plt\n", 679 | "plt.rc('figure', figsize=(10, 6))\n", 680 | "np.set_printoptions(precision=4, suppress=True)" 681 | ] 682 | }, 683 | { 684 | "cell_type": "code", 685 | "execution_count": null, 686 | "metadata": { 687 | "collapsed": true 688 | }, 689 | "outputs": [], 690 | "source": [] 691 | } 692 | ], 693 | "metadata": { 694 | "kernelspec": { 695 | "display_name": "Python 3", 696 | "language": "python", 697 | "name": "python3" 698 | }, 699 | "language_info": { 700 | "codemirror_mode": { 701 | "name": "ipython", 702 | "version": 3 703 | }, 704 | "file_extension": ".py", 705 | "mimetype": "text/x-python", 706 | "name": "python", 707 | "nbconvert_exporter": "python", 708 | "pygments_lexer": "ipython3", 709 | "version": "3.6.1" 710 | } 711 | }, 712 | "nbformat": 4, 713 | "nbformat_minor": 2 714 | } 715 | -------------------------------------------------------------------------------- /pda ch3.v2.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 2, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "data": { 10 | "text/plain": [ 11 | "['BAT', 'CAR', 'DOVE', 'PYTHON']" 12 | ] 13 | }, 14 | "execution_count": 2, 15 | "metadata": {}, 16 | "output_type": "execute_result" 17 | } 18 | ], 19 | "source": [ 20 | "strings = ['a', 'as', 'bat', 'car', 'dove', 'python']\n", 21 | "[x.upper() for x in strings if len(x) > 2]" 22 | ] 23 | }, 24 | { 25 | "cell_type": "code", 26 | "execution_count": 4, 27 | "metadata": {}, 28 | "outputs": [ 29 | { 30 | "name": "stdout", 31 | "output_type": "stream", 32 | "text": [ 33 | "BAT\n", 34 | "CAR\n", 35 | "DOVE\n", 36 | "PYTHON\n" 37 | ] 38 | } 39 | ], 40 | "source": [ 41 | "for x in strings:\n", 42 | " if len(x) > 2:\n", 43 | " print(x.upper())" 44 | ] 45 | }, 46 | { 47 | "cell_type": "code", 48 | "execution_count": 5, 49 | "metadata": {}, 50 | "outputs": [ 51 | { 52 | "data": { 53 | "text/plain": [ 54 | "['BAT', 'CAR', 'DOVE', 'PYTHON']" 55 | ] 56 | }, 57 | "execution_count": 5, 58 | "metadata": {}, 59 | "output_type": "execute_result" 60 | } 61 | ], 62 | "source": [ 63 | "newlist =[]\n", 64 | "for x in strings:\n", 65 | " if len(x) > 2:\n", 66 | " newlist.append(x.upper())\n", 67 | " \n", 68 | "newlist\n" 69 | ] 70 | }, 71 | { 72 | "cell_type": "code", 73 | "execution_count": 6, 74 | "metadata": {}, 75 | "outputs": [ 76 | { 77 | "data": { 78 | "text/plain": [ 79 | "['BAT', 'CAR', 'DOVE', 'PYTHON']" 80 | ] 81 | }, 82 | "execution_count": 6, 83 | "metadata": {}, 84 | "output_type": "execute_result" 85 | } 86 | ], 87 | "source": [ 88 | "newlist =[]\n", 89 | "for x in strings:\n", 90 | " if len(x) > 2:\n", 91 | " newlist.append(x.upper())\n", 92 | " \n", 93 | "newlist\n" 94 | ] 95 | }, 96 | { 97 | "cell_type": "code", 98 | "execution_count": 7, 99 | "metadata": {}, 100 | "outputs": [ 101 | { 102 | "data": { 103 | "text/plain": [ 104 | "set" 105 | ] 106 | }, 107 | "execution_count": 7, 108 | "metadata": {}, 109 | "output_type": "execute_result" 110 | } 111 | ], 112 | "source": [ 113 | "unique_lengths = {len(x) for x in strings}\n", 114 | "type(unique_lengths)" 115 | ] 116 | }, 117 | { 118 | "cell_type": "code", 119 | "execution_count": 8, 120 | "metadata": {}, 121 | "outputs": [ 122 | { 123 | "data": { 124 | "text/plain": [ 125 | "{1, 2, 3, 4, 6}" 126 | ] 127 | }, 128 | "execution_count": 8, 129 | "metadata": {}, 130 | "output_type": "execute_result" 131 | } 132 | ], 133 | "source": [ 134 | "unique_lengths" 135 | ] 136 | }, 137 | { 138 | "cell_type": "code", 139 | "execution_count": 9, 140 | "metadata": {}, 141 | "outputs": [ 142 | { 143 | "data": { 144 | "text/plain": [ 145 | "{'J', 'T'}" 146 | ] 147 | }, 148 | "execution_count": 9, 149 | "metadata": {}, 150 | "output_type": "execute_result" 151 | } 152 | ], 153 | "source": [ 154 | "pythonclasstoday = {'J', 'T', 'S', 'E', 'R'}\n", 155 | "pythontutorsalltime ={'J', 'T', 'Rm'}\n", 156 | "pythonclasstoday & pythontutorsalltime" 157 | ] 158 | }, 159 | { 160 | "cell_type": "code", 161 | "execution_count": 10, 162 | "metadata": {}, 163 | "outputs": [ 164 | { 165 | "data": { 166 | "text/plain": [ 167 | "{1, 2, 3, 4, 6}" 168 | ] 169 | }, 170 | "execution_count": 10, 171 | "metadata": {}, 172 | "output_type": "execute_result" 173 | } 174 | ], 175 | "source": [ 176 | "set(map(len, strings))" 177 | ] 178 | }, 179 | { 180 | "cell_type": "code", 181 | "execution_count": 11, 182 | "metadata": {}, 183 | "outputs": [ 184 | { 185 | "data": { 186 | "text/plain": [ 187 | "['a', 'as', 'bat', 'car', 'dove', 'python']" 188 | ] 189 | }, 190 | "execution_count": 11, 191 | "metadata": {}, 192 | "output_type": "execute_result" 193 | } 194 | ], 195 | "source": [ 196 | "strings" 197 | ] 198 | }, 199 | { 200 | "cell_type": "code", 201 | "execution_count": 13, 202 | "metadata": {}, 203 | "outputs": [ 204 | { 205 | "data": { 206 | "text/plain": [ 207 | "[1, 2, 3, 3, 4, 6]" 208 | ] 209 | }, 210 | "execution_count": 13, 211 | "metadata": {}, 212 | "output_type": "execute_result" 213 | } 214 | ], 215 | "source": [ 216 | "list(map(len, strings))" 217 | ] 218 | }, 219 | { 220 | "cell_type": "code", 221 | "execution_count": 15, 222 | "metadata": {}, 223 | "outputs": [ 224 | { 225 | "data": { 226 | "text/plain": [ 227 | "" 228 | ] 229 | }, 230 | "execution_count": 15, 231 | "metadata": {}, 232 | "output_type": "execute_result" 233 | } 234 | ], 235 | "source": [ 236 | "(map(len, strings))" 237 | ] 238 | }, 239 | { 240 | "cell_type": "code", 241 | "execution_count": 16, 242 | "metadata": {}, 243 | "outputs": [ 244 | { 245 | "data": { 246 | "text/plain": [ 247 | "{'a': 0, 'as': 1, 'bat': 2, 'car': 3, 'dove': 4, 'python': 5}" 248 | ] 249 | }, 250 | "execution_count": 16, 251 | "metadata": {}, 252 | "output_type": "execute_result" 253 | } 254 | ], 255 | "source": [ 256 | "loc_mapping = {val : index for index, val in enumerate(strings)}\n", 257 | "loc_mapping" 258 | ] 259 | }, 260 | { 261 | "cell_type": "code", 262 | "execution_count": 17, 263 | "metadata": {}, 264 | "outputs": [ 265 | { 266 | "name": "stdout", 267 | "output_type": "stream", 268 | "text": [ 269 | "0 a\n", 270 | "1 as\n", 271 | "2 bat\n", 272 | "3 car\n", 273 | "4 dove\n", 274 | "5 python\n" 275 | ] 276 | } 277 | ], 278 | "source": [ 279 | "for index, val in enumerate(strings):\n", 280 | " print(index, val)" 281 | ] 282 | }, 283 | { 284 | "cell_type": "code", 285 | "execution_count": 18, 286 | "metadata": {}, 287 | "outputs": [ 288 | { 289 | "name": "stdout", 290 | "output_type": "stream", 291 | "text": [ 292 | "[]\n" 293 | ] 294 | } 295 | ], 296 | "source": [ 297 | "a = None\n", 298 | "def bind_a_variable():\n", 299 | " global a\n", 300 | " a = []\n", 301 | "bind_a_variable()\n", 302 | "print(a)" 303 | ] 304 | }, 305 | { 306 | "cell_type": "code", 307 | "execution_count": 19, 308 | "metadata": {}, 309 | "outputs": [ 310 | { 311 | "data": { 312 | "text/plain": [ 313 | "['Alabama',\n", 314 | " 'Georgia',\n", 315 | " 'Georgia',\n", 316 | " 'Georgia',\n", 317 | " 'Florida',\n", 318 | " 'South Carolina',\n", 319 | " 'West Virginia']" 320 | ] 321 | }, 322 | "execution_count": 19, 323 | "metadata": {}, 324 | "output_type": "execute_result" 325 | } 326 | ], 327 | "source": [ 328 | "states = [' Alabama ', 'Georgia!', 'Georgia', 'georgia', 'FlOrIda',\n", 329 | " 'south carolina##', 'West virginia?']\n", 330 | "import re\n", 331 | "\n", 332 | "def clean_strings(strings):\n", 333 | " result = []\n", 334 | " for value in strings:\n", 335 | " value = value.strip()\n", 336 | " value = re.sub('[!#?]', '', value)\n", 337 | " value = value.title()\n", 338 | " result.append(value)\n", 339 | " return result\n", 340 | "clean_strings(states)\n" 341 | ] 342 | }, 343 | { 344 | "cell_type": "code", 345 | "execution_count": 20, 346 | "metadata": {}, 347 | "outputs": [ 348 | { 349 | "data": { 350 | "text/plain": [ 351 | "['Alabama',\n", 352 | " 'Georgia',\n", 353 | " 'Georgia',\n", 354 | " 'Georgia',\n", 355 | " 'Florida',\n", 356 | " 'South Carolina',\n", 357 | " 'West Virginia']" 358 | ] 359 | }, 360 | "execution_count": 20, 361 | "metadata": {}, 362 | "output_type": "execute_result" 363 | } 364 | ], 365 | "source": [ 366 | "def remove_punctuation(value):\n", 367 | " return re.sub('[!#?]', '', value)\n", 368 | "\n", 369 | "clean_ops = [str.strip, remove_punctuation, str.title]\n", 370 | "\n", 371 | "def clean_strings(strings, ops):\n", 372 | " result = []\n", 373 | " for value in strings:\n", 374 | " for function in ops:\n", 375 | " value = function(value)\n", 376 | " result.append(value)\n", 377 | " return result\n", 378 | "clean_strings(states, clean_ops)" 379 | ] 380 | }, 381 | { 382 | "cell_type": "code", 383 | "execution_count": 21, 384 | "metadata": {}, 385 | "outputs": [ 386 | { 387 | "data": { 388 | "text/plain": [ 389 | "[' Alabama ',\n", 390 | " 'Georgia',\n", 391 | " 'Georgia',\n", 392 | " 'georgia',\n", 393 | " 'FlOrIda',\n", 394 | " 'south carolina',\n", 395 | " 'West virginia']" 396 | ] 397 | }, 398 | "execution_count": 21, 399 | "metadata": {}, 400 | "output_type": "execute_result" 401 | } 402 | ], 403 | "source": [ 404 | "list(map(remove_punctuation, states))" 405 | ] 406 | }, 407 | { 408 | "cell_type": "code", 409 | "execution_count": 22, 410 | "metadata": { 411 | "collapsed": true 412 | }, 413 | "outputs": [], 414 | "source": [ 415 | "strings = ['foo', 'card', 'bar', 'aaaa', 'abab']\n" 416 | ] 417 | }, 418 | { 419 | "cell_type": "code", 420 | "execution_count": 23, 421 | "metadata": {}, 422 | "outputs": [ 423 | { 424 | "data": { 425 | "text/plain": [ 426 | "['aaaa', 'foo', 'abab', 'bar', 'card']" 427 | ] 428 | }, 429 | "execution_count": 23, 430 | "metadata": {}, 431 | "output_type": "execute_result" 432 | } 433 | ], 434 | "source": [ 435 | "strings.sort(key=lambda x: len(set(list(x))))\n", 436 | "strings" 437 | ] 438 | }, 439 | { 440 | "cell_type": "code", 441 | "execution_count": 24, 442 | "metadata": {}, 443 | "outputs": [ 444 | { 445 | "name": "stdout", 446 | "output_type": "stream", 447 | "text": [ 448 | "30\n" 449 | ] 450 | } 451 | ], 452 | "source": [ 453 | "x = lambda a, b : a * b\n", 454 | "print(x(5, 6))" 455 | ] 456 | }, 457 | { 458 | "cell_type": "code", 459 | "execution_count": 25, 460 | "metadata": {}, 461 | "outputs": [ 462 | { 463 | "data": { 464 | "text/plain": [ 465 | "(x)>" 466 | ] 467 | }, 468 | "execution_count": 25, 469 | "metadata": {}, 470 | "output_type": "execute_result" 471 | } 472 | ], 473 | "source": [ 474 | "lambda x: len(set(list(x)))" 475 | ] 476 | }, 477 | { 478 | "cell_type": "code", 479 | "execution_count": 27, 480 | "metadata": {}, 481 | "outputs": [ 482 | { 483 | "data": { 484 | "text/plain": [ 485 | "['j', 'o', 's', 'h', 'i']" 486 | ] 487 | }, 488 | "execution_count": 27, 489 | "metadata": {}, 490 | "output_type": "execute_result" 491 | } 492 | ], 493 | "source": [ 494 | "list(\"joshi\")" 495 | ] 496 | }, 497 | { 498 | "cell_type": "code", 499 | "execution_count": 29, 500 | "metadata": {}, 501 | "outputs": [ 502 | { 503 | "data": { 504 | "text/plain": [ 505 | "5" 506 | ] 507 | }, 508 | "execution_count": 29, 509 | "metadata": {}, 510 | "output_type": "execute_result" 511 | } 512 | ], 513 | "source": [ 514 | "len(set(list(\"joshi\")))" 515 | ] 516 | }, 517 | { 518 | "cell_type": "code", 519 | "execution_count": 30, 520 | "metadata": {}, 521 | "outputs": [ 522 | { 523 | "data": { 524 | "text/plain": [ 525 | "['a', 'a', 'a', 'a']" 526 | ] 527 | }, 528 | "execution_count": 30, 529 | "metadata": {}, 530 | "output_type": "execute_result" 531 | } 532 | ], 533 | "source": [ 534 | "x = list('aaaa')\n", 535 | "x" 536 | ] 537 | }, 538 | { 539 | "cell_type": "code", 540 | "execution_count": 32, 541 | "metadata": {}, 542 | "outputs": [ 543 | { 544 | "data": { 545 | "text/plain": [ 546 | "{'a'}" 547 | ] 548 | }, 549 | "execution_count": 32, 550 | "metadata": {}, 551 | "output_type": "execute_result" 552 | } 553 | ], 554 | "source": [ 555 | "y= set(x)\n", 556 | "y" 557 | ] 558 | }, 559 | { 560 | "cell_type": "code", 561 | "execution_count": 33, 562 | "metadata": {}, 563 | "outputs": [ 564 | { 565 | "data": { 566 | "text/plain": [ 567 | "1" 568 | ] 569 | }, 570 | "execution_count": 33, 571 | "metadata": {}, 572 | "output_type": "execute_result" 573 | } 574 | ], 575 | "source": [ 576 | "z= len(y)\n", 577 | "z" 578 | ] 579 | }, 580 | { 581 | "cell_type": "code", 582 | "execution_count": 34, 583 | "metadata": {}, 584 | "outputs": [ 585 | { 586 | "data": { 587 | "text/plain": [ 588 | "['aaaa', 'foo', 'abab', 'bar', 'card']" 589 | ] 590 | }, 591 | "execution_count": 34, 592 | "metadata": {}, 593 | "output_type": "execute_result" 594 | } 595 | ], 596 | "source": [ 597 | "def myfun(inputstring):\n", 598 | " return len(set(list(inputstring)))\n", 599 | "strings = ['foo', 'card', 'bar', 'aaaa', 'abab']\n", 600 | "strings.sort(key=myfun)\n", 601 | "strings" 602 | ] 603 | }, 604 | { 605 | "cell_type": "code", 606 | "execution_count": 35, 607 | "metadata": {}, 608 | "outputs": [ 609 | { 610 | "data": { 611 | "text/plain": [ 612 | "1.2345" 613 | ] 614 | }, 615 | "execution_count": 35, 616 | "metadata": {}, 617 | "output_type": "execute_result" 618 | } 619 | ], 620 | "source": [ 621 | "float('1.2345')" 622 | ] 623 | }, 624 | { 625 | "cell_type": "code", 626 | "execution_count": 36, 627 | "metadata": {}, 628 | "outputs": [ 629 | { 630 | "data": { 631 | "text/plain": [ 632 | "1.2345" 633 | ] 634 | }, 635 | "execution_count": 36, 636 | "metadata": {}, 637 | "output_type": "execute_result" 638 | } 639 | ], 640 | "source": [ 641 | "float('1.2345')" 642 | ] 643 | }, 644 | { 645 | "cell_type": "code", 646 | "execution_count": 37, 647 | "metadata": { 648 | "collapsed": true 649 | }, 650 | "outputs": [], 651 | "source": [ 652 | "def attempt_float(x):\n", 653 | " try:\n", 654 | " return float(x)\n", 655 | " except:\n", 656 | " return x" 657 | ] 658 | }, 659 | { 660 | "cell_type": "code", 661 | "execution_count": 38, 662 | "metadata": {}, 663 | "outputs": [ 664 | { 665 | "ename": "TypeError", 666 | "evalue": "float() argument must be a string or a number, not 'tuple'", 667 | "output_type": "error", 668 | "traceback": [ 669 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 670 | "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", 671 | "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mfloat\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m2\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", 672 | "\u001b[1;31mTypeError\u001b[0m: float() argument must be a string or a number, not 'tuple'" 673 | ] 674 | } 675 | ], 676 | "source": [ 677 | "float((1, 2))" 678 | ] 679 | }, 680 | { 681 | "cell_type": "code", 682 | "execution_count": 39, 683 | "metadata": {}, 684 | "outputs": [ 685 | { 686 | "data": { 687 | "text/plain": [ 688 | "(1, 2)" 689 | ] 690 | }, 691 | "execution_count": 39, 692 | "metadata": {}, 693 | "output_type": "execute_result" 694 | } 695 | ], 696 | "source": [ 697 | "attempt_float((1, 2))" 698 | ] 699 | }, 700 | { 701 | "cell_type": "code", 702 | "execution_count": 40, 703 | "metadata": { 704 | "collapsed": true 705 | }, 706 | "outputs": [], 707 | "source": [ 708 | "import numpy as np\n", 709 | "np.random.seed(12345)\n", 710 | "import matplotlib.pyplot as plt\n", 711 | "plt.rc('figure', figsize=(10, 6))\n", 712 | "np.set_printoptions(precision=4, suppress=True)" 713 | ] 714 | }, 715 | { 716 | "cell_type": "code", 717 | "execution_count": null, 718 | "metadata": { 719 | "collapsed": true 720 | }, 721 | "outputs": [], 722 | "source": [] 723 | } 724 | ], 725 | "metadata": { 726 | "kernelspec": { 727 | "display_name": "Python 3", 728 | "language": "python", 729 | "name": "python3" 730 | }, 731 | "language_info": { 732 | "codemirror_mode": { 733 | "name": "ipython", 734 | "version": 3 735 | }, 736 | "file_extension": ".py", 737 | "mimetype": "text/x-python", 738 | "name": "python", 739 | "nbconvert_exporter": "python", 740 | "pygments_lexer": "ipython3", 741 | "version": "3.6.1" 742 | } 743 | }, 744 | "nbformat": 4, 745 | "nbformat_minor": 2 746 | } 747 | -------------------------------------------------------------------------------- /pda ch5.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 8, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import pandas as pd\n", 10 | "from pandas import Series, DataFrame\n", 11 | "import numpy as np\n", 12 | "np.random.seed(12345)\n", 13 | "import matplotlib.pyplot as plt\n", 14 | "plt.rc('figure', figsize=(10, 6))\n", 15 | "PREVIOUS_MAX_ROWS = pd.options.display.max_rows\n", 16 | "pd.options.display.max_rows = 20\n", 17 | "np.set_printoptions(precision=4, suppress=True)\n" 18 | ] 19 | }, 20 | { 21 | "cell_type": "code", 22 | "execution_count": 26, 23 | "metadata": {}, 24 | "outputs": [ 25 | { 26 | "data": { 27 | "text/plain": [ 28 | "0 4\n", 29 | "1 7\n", 30 | "2 -5\n", 31 | "3 3\n", 32 | "4 11\n", 33 | "5 12\n", 34 | "6 12\n", 35 | "dtype: int64" 36 | ] 37 | }, 38 | "execution_count": 26, 39 | "metadata": {}, 40 | "output_type": "execute_result" 41 | } 42 | ], 43 | "source": [ 44 | "obj = pd.Series([4, 7, -5, 3,11,12,12])\n", 45 | "obj" 46 | ] 47 | }, 48 | { 49 | "cell_type": "code", 50 | "execution_count": 10, 51 | "metadata": {}, 52 | "outputs": [ 53 | { 54 | "data": { 55 | "text/plain": [ 56 | "RangeIndex(start=0, stop=4, step=1)" 57 | ] 58 | }, 59 | "execution_count": 10, 60 | "metadata": {}, 61 | "output_type": "execute_result" 62 | } 63 | ], 64 | "source": [ 65 | "obj.index # like range(4)\n" 66 | ] 67 | }, 68 | { 69 | "cell_type": "code", 70 | "execution_count": 11, 71 | "metadata": {}, 72 | "outputs": [ 73 | { 74 | "data": { 75 | "text/plain": [ 76 | "array([ 4, 7, -5, 3], dtype=int64)" 77 | ] 78 | }, 79 | "execution_count": 11, 80 | "metadata": {}, 81 | "output_type": "execute_result" 82 | } 83 | ], 84 | "source": [ 85 | "obj.values\n" 86 | ] 87 | }, 88 | { 89 | "cell_type": "code", 90 | "execution_count": 12, 91 | "metadata": {}, 92 | "outputs": [ 93 | { 94 | "data": { 95 | "text/plain": [ 96 | "d 4\n", 97 | "b 7\n", 98 | "a -5\n", 99 | "c 3\n", 100 | "dtype: int64" 101 | ] 102 | }, 103 | "execution_count": 12, 104 | "metadata": {}, 105 | "output_type": "execute_result" 106 | } 107 | ], 108 | "source": [ 109 | "obj2 = pd.Series([4, 7, -5, 3], index=['d', 'b', 'a', 'c'])\n", 110 | "obj2" 111 | ] 112 | }, 113 | { 114 | "cell_type": "code", 115 | "execution_count": 13, 116 | "metadata": {}, 117 | "outputs": [ 118 | { 119 | "data": { 120 | "text/plain": [ 121 | "Index(['d', 'b', 'a', 'c'], dtype='object')" 122 | ] 123 | }, 124 | "execution_count": 13, 125 | "metadata": {}, 126 | "output_type": "execute_result" 127 | } 128 | ], 129 | "source": [ 130 | "\n", 131 | "obj2.index\n", 132 | "\n" 133 | ] 134 | }, 135 | { 136 | "cell_type": "code", 137 | "execution_count": 14, 138 | "metadata": {}, 139 | "outputs": [ 140 | { 141 | "data": { 142 | "text/plain": [ 143 | "-5" 144 | ] 145 | }, 146 | "execution_count": 14, 147 | "metadata": {}, 148 | "output_type": "execute_result" 149 | } 150 | ], 151 | "source": [ 152 | "obj2['a']\n" 153 | ] 154 | }, 155 | { 156 | "cell_type": "code", 157 | "execution_count": 17, 158 | "metadata": {}, 159 | "outputs": [ 160 | { 161 | "data": { 162 | "text/plain": [ 163 | "6" 164 | ] 165 | }, 166 | "execution_count": 17, 167 | "metadata": {}, 168 | "output_type": "execute_result" 169 | } 170 | ], 171 | "source": [ 172 | "obj2['d']\n" 173 | ] 174 | }, 175 | { 176 | "cell_type": "code", 177 | "execution_count": 18, 178 | "metadata": {}, 179 | "outputs": [ 180 | { 181 | "data": { 182 | "text/plain": [ 183 | "d 9\n", 184 | "b 7\n", 185 | "a -5\n", 186 | "c 3\n", 187 | "dtype: int64" 188 | ] 189 | }, 190 | "execution_count": 18, 191 | "metadata": {}, 192 | "output_type": "execute_result" 193 | } 194 | ], 195 | "source": [ 196 | "obj2['d'] = 9\n", 197 | "obj2" 198 | ] 199 | }, 200 | { 201 | "cell_type": "code", 202 | "execution_count": 19, 203 | "metadata": {}, 204 | "outputs": [ 205 | { 206 | "data": { 207 | "text/plain": [ 208 | "d 9\n", 209 | "b 7\n", 210 | "a -5\n", 211 | "c 3\n", 212 | "dtype: int64" 213 | ] 214 | }, 215 | "execution_count": 19, 216 | "metadata": {}, 217 | "output_type": "execute_result" 218 | } 219 | ], 220 | "source": [ 221 | "obj2" 222 | ] 223 | }, 224 | { 225 | "cell_type": "code", 226 | "execution_count": 20, 227 | "metadata": {}, 228 | "outputs": [ 229 | { 230 | "data": { 231 | "text/plain": [ 232 | "c 3\n", 233 | "a -5\n", 234 | "d 9\n", 235 | "dtype: int64" 236 | ] 237 | }, 238 | "execution_count": 20, 239 | "metadata": {}, 240 | "output_type": "execute_result" 241 | } 242 | ], 243 | "source": [ 244 | "obj2[['c', 'a', 'd']]" 245 | ] 246 | }, 247 | { 248 | "cell_type": "code", 249 | "execution_count": 21, 250 | "metadata": {}, 251 | "outputs": [ 252 | { 253 | "data": { 254 | "text/plain": [ 255 | "d 9\n", 256 | "b 7\n", 257 | "c 3\n", 258 | "dtype: int64" 259 | ] 260 | }, 261 | "execution_count": 21, 262 | "metadata": {}, 263 | "output_type": "execute_result" 264 | } 265 | ], 266 | "source": [ 267 | "obj2[obj2 > 0]" 268 | ] 269 | }, 270 | { 271 | "cell_type": "code", 272 | "execution_count": 22, 273 | "metadata": {}, 274 | "outputs": [ 275 | { 276 | "data": { 277 | "text/plain": [ 278 | "d True\n", 279 | "b True\n", 280 | "a False\n", 281 | "c True\n", 282 | "dtype: bool" 283 | ] 284 | }, 285 | "execution_count": 22, 286 | "metadata": {}, 287 | "output_type": "execute_result" 288 | } 289 | ], 290 | "source": [ 291 | "obj2 > 0" 292 | ] 293 | }, 294 | { 295 | "cell_type": "code", 296 | "execution_count": 23, 297 | "metadata": {}, 298 | "outputs": [ 299 | { 300 | "data": { 301 | "text/plain": [ 302 | "d 8103.083928\n", 303 | "b 1096.633158\n", 304 | "a 0.006738\n", 305 | "c 20.085537\n", 306 | "dtype: float64" 307 | ] 308 | }, 309 | "execution_count": 23, 310 | "metadata": {}, 311 | "output_type": "execute_result" 312 | } 313 | ], 314 | "source": [ 315 | "np.exp(obj2)" 316 | ] 317 | }, 318 | { 319 | "cell_type": "code", 320 | "execution_count": 24, 321 | "metadata": {}, 322 | "outputs": [ 323 | { 324 | "data": { 325 | "text/plain": [ 326 | "Ohio 35000\n", 327 | "Oregon 16000\n", 328 | "Texas 71000\n", 329 | "Utah 5000\n", 330 | "dtype: int64" 331 | ] 332 | }, 333 | "execution_count": 24, 334 | "metadata": {}, 335 | "output_type": "execute_result" 336 | } 337 | ], 338 | "source": [ 339 | "sdata = {'Ohio': 35000, 'Texas': 71000, 'Oregon': 16000, 'Utah': 5000}\n", 340 | "\n", 341 | "obj3 = pd.Series(sdata)\n", 342 | "obj3" 343 | ] 344 | }, 345 | { 346 | "cell_type": "code", 347 | "execution_count": 25, 348 | "metadata": {}, 349 | "outputs": [ 350 | { 351 | "data": { 352 | "text/plain": [ 353 | "Index(['Ohio', 'Oregon', 'Texas', 'Utah'], dtype='object')" 354 | ] 355 | }, 356 | "execution_count": 25, 357 | "metadata": {}, 358 | "output_type": "execute_result" 359 | } 360 | ], 361 | "source": [ 362 | "obj3.index" 363 | ] 364 | }, 365 | { 366 | "cell_type": "code", 367 | "execution_count": 27, 368 | "metadata": {}, 369 | "outputs": [ 370 | { 371 | "data": { 372 | "text/plain": [ 373 | "dict" 374 | ] 375 | }, 376 | "execution_count": 27, 377 | "metadata": {}, 378 | "output_type": "execute_result" 379 | } 380 | ], 381 | "source": [ 382 | "type(sdata)" 383 | ] 384 | }, 385 | { 386 | "cell_type": "code", 387 | "execution_count": 28, 388 | "metadata": {}, 389 | "outputs": [ 390 | { 391 | "data": { 392 | "text/plain": [ 393 | "pandas.core.series.Series" 394 | ] 395 | }, 396 | "execution_count": 28, 397 | "metadata": {}, 398 | "output_type": "execute_result" 399 | } 400 | ], 401 | "source": [ 402 | "type(obj3)" 403 | ] 404 | }, 405 | { 406 | "cell_type": "code", 407 | "execution_count": null, 408 | "metadata": { 409 | "collapsed": true 410 | }, 411 | "outputs": [], 412 | "source": [] 413 | } 414 | ], 415 | "metadata": { 416 | "kernelspec": { 417 | "display_name": "Python 3", 418 | "language": "python", 419 | "name": "python3" 420 | }, 421 | "language_info": { 422 | "codemirror_mode": { 423 | "name": "ipython", 424 | "version": 3 425 | }, 426 | "file_extension": ".py", 427 | "mimetype": "text/x-python", 428 | "name": "python", 429 | "nbconvert_exporter": "python", 430 | "pygments_lexer": "ipython3", 431 | "version": "3.6.1" 432 | } 433 | }, 434 | "nbformat": 4, 435 | "nbformat_minor": 2 436 | } 437 | -------------------------------------------------------------------------------- /pda san-ch4.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 2, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "data": { 10 | "text/plain": [ 11 | "array([6. , 7.5, 8. , 0. , 1. ])" 12 | ] 13 | }, 14 | "execution_count": 2, 15 | "metadata": {}, 16 | "output_type": "execute_result" 17 | } 18 | ], 19 | "source": [ 20 | "import numpy as np\n", 21 | "data1 = [6, 7.5, 8, 0, 1]\n", 22 | "arr1 = np.array(data1)\n", 23 | "arr1" 24 | ] 25 | }, 26 | { 27 | "cell_type": "code", 28 | "execution_count": 3, 29 | "metadata": {}, 30 | "outputs": [ 31 | { 32 | "data": { 33 | "text/plain": [ 34 | "dtype('int32')" 35 | ] 36 | }, 37 | "execution_count": 3, 38 | "metadata": {}, 39 | "output_type": "execute_result" 40 | } 41 | ], 42 | "source": [ 43 | "arr1 = np.array([1, 2, 3], dtype=np.float64)\n", 44 | "arr2 = np.array([1, 2, 3], dtype=np.int32)\n", 45 | "arr1.dtype\n", 46 | "arr2.dtype" 47 | ] 48 | }, 49 | { 50 | "cell_type": "code", 51 | "execution_count": 4, 52 | "metadata": {}, 53 | "outputs": [ 54 | { 55 | "data": { 56 | "text/plain": [ 57 | "array([[1, 2, 3, 4],\n", 58 | " [5, 6, 7, 8]])" 59 | ] 60 | }, 61 | "execution_count": 4, 62 | "metadata": {}, 63 | "output_type": "execute_result" 64 | } 65 | ], 66 | "source": [ 67 | "data2 = [[1, 2, 3, 4], [5, 6, 7, 8]]\n", 68 | "arr2 = np.array(data2)\n", 69 | "arr2" 70 | ] 71 | }, 72 | { 73 | "cell_type": "code", 74 | "execution_count": 5, 75 | "metadata": {}, 76 | "outputs": [ 77 | { 78 | "data": { 79 | "text/plain": [ 80 | "array([[1, 2, 3, 4],\n", 81 | " [5, 6, 7, 8]])" 82 | ] 83 | }, 84 | "execution_count": 5, 85 | "metadata": {}, 86 | "output_type": "execute_result" 87 | } 88 | ], 89 | "source": [ 90 | "data2 = [[1, 2, 3, 4], [5, 6, 7, 8]]\n", 91 | "arr2 = np.array(data2)\n", 92 | "arr2" 93 | ] 94 | }, 95 | { 96 | "cell_type": "code", 97 | "execution_count": 6, 98 | "metadata": {}, 99 | "outputs": [ 100 | { 101 | "data": { 102 | "text/plain": [ 103 | "(2, 4)" 104 | ] 105 | }, 106 | "execution_count": 6, 107 | "metadata": {}, 108 | "output_type": "execute_result" 109 | } 110 | ], 111 | "source": [ 112 | "arr2.shape" 113 | ] 114 | }, 115 | { 116 | "cell_type": "code", 117 | "execution_count": 7, 118 | "metadata": {}, 119 | "outputs": [ 120 | { 121 | "data": { 122 | "text/plain": [ 123 | "array([1, 2, 3, 4])" 124 | ] 125 | }, 126 | "execution_count": 7, 127 | "metadata": {}, 128 | "output_type": "execute_result" 129 | } 130 | ], 131 | "source": [ 132 | "arr2[0]" 133 | ] 134 | }, 135 | { 136 | "cell_type": "code", 137 | "execution_count": 9, 138 | "metadata": {}, 139 | "outputs": [ 140 | { 141 | "data": { 142 | "text/plain": [ 143 | "array([5, 6, 7, 8])" 144 | ] 145 | }, 146 | "execution_count": 9, 147 | "metadata": {}, 148 | "output_type": "execute_result" 149 | } 150 | ], 151 | "source": [ 152 | "arr2[1]" 153 | ] 154 | }, 155 | { 156 | "cell_type": "code", 157 | "execution_count": 10, 158 | "metadata": {}, 159 | "outputs": [ 160 | { 161 | "data": { 162 | "text/plain": [ 163 | "(3,)" 164 | ] 165 | }, 166 | "execution_count": 10, 167 | "metadata": {}, 168 | "output_type": "execute_result" 169 | } 170 | ], 171 | "source": [ 172 | "arr1.shape" 173 | ] 174 | }, 175 | { 176 | "cell_type": "code", 177 | "execution_count": 11, 178 | "metadata": {}, 179 | "outputs": [ 180 | { 181 | "data": { 182 | "text/plain": [ 183 | "array([1., 2., 3.])" 184 | ] 185 | }, 186 | "execution_count": 11, 187 | "metadata": {}, 188 | "output_type": "execute_result" 189 | } 190 | ], 191 | "source": [ 192 | "arr1" 193 | ] 194 | }, 195 | { 196 | "cell_type": "code", 197 | "execution_count": 12, 198 | "metadata": {}, 199 | "outputs": [ 200 | { 201 | "data": { 202 | "text/plain": [ 203 | "(2, 2, 3)" 204 | ] 205 | }, 206 | "execution_count": 12, 207 | "metadata": {}, 208 | "output_type": "execute_result" 209 | } 210 | ], 211 | "source": [ 212 | "data2 = [[[1, 2,4], [3, 4,5]], [[5, 6,5], [7, 8,11]]]\n", 213 | "arr3 = np.array(data2)\n", 214 | "arr3.shape" 215 | ] 216 | }, 217 | { 218 | "cell_type": "code", 219 | "execution_count": 13, 220 | "metadata": {}, 221 | "outputs": [ 222 | { 223 | "data": { 224 | "text/plain": [ 225 | "array([[1, 2, 4],\n", 226 | " [3, 4, 5]])" 227 | ] 228 | }, 229 | "execution_count": 13, 230 | "metadata": {}, 231 | "output_type": "execute_result" 232 | } 233 | ], 234 | "source": [ 235 | "arr3[0]" 236 | ] 237 | }, 238 | { 239 | "cell_type": "code", 240 | "execution_count": 14, 241 | "metadata": {}, 242 | "outputs": [ 243 | { 244 | "data": { 245 | "text/plain": [ 246 | "array([ 3.7, -1.2, -2.6, 0.5, 12.9, 10.1])" 247 | ] 248 | }, 249 | "execution_count": 14, 250 | "metadata": {}, 251 | "output_type": "execute_result" 252 | } 253 | ], 254 | "source": [ 255 | "arr = np.array([3.7, -1.2, -2.6, 0.5, 12.9, 10.1])\n", 256 | "arr" 257 | ] 258 | }, 259 | { 260 | "cell_type": "code", 261 | "execution_count": null, 262 | "metadata": {}, 263 | "outputs": [], 264 | "source": [ 265 | "\n", 266 | "\n", 267 | "\n" 268 | ] 269 | }, 270 | { 271 | "cell_type": "code", 272 | "execution_count": 17, 273 | "metadata": {}, 274 | "outputs": [ 275 | { 276 | "data": { 277 | "text/plain": [ 278 | "array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])" 279 | ] 280 | }, 281 | "execution_count": 17, 282 | "metadata": {}, 283 | "output_type": "execute_result" 284 | } 285 | ], 286 | "source": [ 287 | "np.zeros(10)" 288 | ] 289 | }, 290 | { 291 | "cell_type": "code", 292 | "execution_count": 18, 293 | "metadata": {}, 294 | "outputs": [ 295 | { 296 | "data": { 297 | "text/plain": [ 298 | "array([[0., 0., 0., 0., 0., 0.],\n", 299 | " [0., 0., 0., 0., 0., 0.],\n", 300 | " [0., 0., 0., 0., 0., 0.]])" 301 | ] 302 | }, 303 | "execution_count": 18, 304 | "metadata": {}, 305 | "output_type": "execute_result" 306 | } 307 | ], 308 | "source": [ 309 | "np.zeros((3, 6))" 310 | ] 311 | }, 312 | { 313 | "cell_type": "code", 314 | "execution_count": 19, 315 | "metadata": {}, 316 | "outputs": [ 317 | { 318 | "data": { 319 | "text/plain": [ 320 | "array([[[0., 0.],\n", 321 | " [0., 0.],\n", 322 | " [0., 0.]],\n", 323 | "\n", 324 | " [[0., 0.],\n", 325 | " [0., 0.],\n", 326 | " [0., 0.]]])" 327 | ] 328 | }, 329 | "execution_count": 19, 330 | "metadata": {}, 331 | "output_type": "execute_result" 332 | } 333 | ], 334 | "source": [ 335 | "np.empty((2, 3, 2))" 336 | ] 337 | }, 338 | { 339 | "cell_type": "code", 340 | "execution_count": 15, 341 | "metadata": {}, 342 | "outputs": [ 343 | { 344 | "name": "stdout", 345 | "output_type": "stream", 346 | "text": [ 347 | "[ 3.7 -1.2 -2.6 0.5 12.9 10.1]\n", 348 | "float64\n" 349 | ] 350 | }, 351 | { 352 | "data": { 353 | "text/plain": [ 354 | "array([ 3, -1, -2, 0, 12, 10])" 355 | ] 356 | }, 357 | "execution_count": 15, 358 | "metadata": {}, 359 | "output_type": "execute_result" 360 | } 361 | ], 362 | "source": [ 363 | "arr = np.array([3.7, -1.2, -2.6, 0.5, 12.9, 10.1])\n", 364 | "print(arr)\n", 365 | "print(arr.dtype)\n", 366 | "arr.astype(int)" 367 | ] 368 | }, 369 | { 370 | "cell_type": "code", 371 | "execution_count": 21, 372 | "metadata": {}, 373 | "outputs": [ 374 | { 375 | "data": { 376 | "text/plain": [ 377 | "array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])" 378 | ] 379 | }, 380 | "execution_count": 21, 381 | "metadata": {}, 382 | "output_type": "execute_result" 383 | } 384 | ], 385 | "source": [ 386 | "np.arange(15)" 387 | ] 388 | }, 389 | { 390 | "cell_type": "code", 391 | "execution_count": 22, 392 | "metadata": {}, 393 | "outputs": [ 394 | { 395 | "data": { 396 | "text/plain": [ 397 | "array([0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2], dtype=int32)" 398 | ] 399 | }, 400 | "execution_count": 22, 401 | "metadata": {}, 402 | "output_type": "execute_result" 403 | } 404 | ], 405 | "source": [ 406 | "np.arange(15)%3" 407 | ] 408 | }, 409 | { 410 | "cell_type": "code", 411 | "execution_count": 23, 412 | "metadata": {}, 413 | "outputs": [ 414 | { 415 | "data": { 416 | "text/plain": [ 417 | "array([0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4], dtype=int32)" 418 | ] 419 | }, 420 | "execution_count": 23, 421 | "metadata": {}, 422 | "output_type": "execute_result" 423 | } 424 | ], 425 | "source": [ 426 | "np.arange(15)//3" 427 | ] 428 | }, 429 | { 430 | "cell_type": "code", 431 | "execution_count": 25, 432 | "metadata": {}, 433 | "outputs": [ 434 | { 435 | "data": { 436 | "text/plain": [ 437 | "array([1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 1], dtype=int32)" 438 | ] 439 | }, 440 | "execution_count": 25, 441 | "metadata": {}, 442 | "output_type": "execute_result" 443 | } 444 | ], 445 | "source": [ 446 | "np.arange(15)%7+1" 447 | ] 448 | }, 449 | { 450 | "cell_type": "code", 451 | "execution_count": 26, 452 | "metadata": {}, 453 | "outputs": [ 454 | { 455 | "data": { 456 | "text/plain": [ 457 | "dtype('float64')" 458 | ] 459 | }, 460 | "execution_count": 26, 461 | "metadata": {}, 462 | "output_type": "execute_result" 463 | } 464 | ], 465 | "source": [ 466 | "float_arr = arr.astype(np.float64)\n", 467 | "float_arr.dtype" 468 | ] 469 | }, 470 | { 471 | "cell_type": "code", 472 | "execution_count": 27, 473 | "metadata": {}, 474 | "outputs": [ 475 | { 476 | "data": { 477 | "text/plain": [ 478 | "array([ 1.25, -9.6 , 42. ])" 479 | ] 480 | }, 481 | "execution_count": 27, 482 | "metadata": {}, 483 | "output_type": "execute_result" 484 | } 485 | ], 486 | "source": [ 487 | "numeric_strings = np.array(['1.25', '-9.6', '42'], dtype=np.string_)\n", 488 | "numeric_strings.astype(float)" 489 | ] 490 | }, 491 | { 492 | "cell_type": "code", 493 | "execution_count": 28, 494 | "metadata": {}, 495 | "outputs": [ 496 | { 497 | "data": { 498 | "text/plain": [ 499 | "1" 500 | ] 501 | }, 502 | "execution_count": 28, 503 | "metadata": {}, 504 | "output_type": "execute_result" 505 | } 506 | ], 507 | "source": [ 508 | "j=[1.9,2.2,3.3]\n", 509 | "int(j[0])" 510 | ] 511 | }, 512 | { 513 | "cell_type": "code", 514 | "execution_count": 30, 515 | "metadata": {}, 516 | "outputs": [], 517 | "source": [ 518 | "arr = np.array([[1., 2., 3.], [4., 5., 6.]])\n" 519 | ] 520 | }, 521 | { 522 | "cell_type": "code", 523 | "execution_count": 31, 524 | "metadata": {}, 525 | "outputs": [ 526 | { 527 | "data": { 528 | "text/plain": [ 529 | "array([[0., 0., 0.],\n", 530 | " [0., 0., 0.]])" 531 | ] 532 | }, 533 | "execution_count": 31, 534 | "metadata": {}, 535 | "output_type": "execute_result" 536 | } 537 | ], 538 | "source": [ 539 | "arr\n", 540 | "arr * arr\n", 541 | "arr - arr" 542 | ] 543 | }, 544 | { 545 | "cell_type": "code", 546 | "execution_count": 32, 547 | "metadata": {}, 548 | "outputs": [ 549 | { 550 | "data": { 551 | "text/plain": [ 552 | "array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])" 553 | ] 554 | }, 555 | "execution_count": 32, 556 | "metadata": {}, 557 | "output_type": "execute_result" 558 | } 559 | ], 560 | "source": [ 561 | "arr = np.arange(10)\n", 562 | "arr" 563 | ] 564 | }, 565 | { 566 | "cell_type": "code", 567 | "execution_count": 33, 568 | "metadata": {}, 569 | "outputs": [ 570 | { 571 | "name": "stderr", 572 | "output_type": "stream", 573 | "text": [ 574 | "C:\\Users\\xxx.XXX\\Anaconda3\\lib\\site-packages\\ipykernel_launcher.py:1: RuntimeWarning: divide by zero encountered in true_divide\n", 575 | " \"\"\"Entry point for launching an IPython kernel.\n" 576 | ] 577 | }, 578 | { 579 | "data": { 580 | "text/plain": [ 581 | "array([0. , 1. , 1.41421356, 1.73205081, 2. ,\n", 582 | " 2.23606798, 2.44948974, 2.64575131, 2.82842712, 3. ])" 583 | ] 584 | }, 585 | "execution_count": 33, 586 | "metadata": {}, 587 | "output_type": "execute_result" 588 | } 589 | ], 590 | "source": [ 591 | "1 / arr\n", 592 | "arr ** 0.5" 593 | ] 594 | }, 595 | { 596 | "cell_type": "code", 597 | "execution_count": 35, 598 | "metadata": {}, 599 | "outputs": [], 600 | "source": [ 601 | "arr2 = np.array([[0., 4., 1.], [7., 2., 12.]])\n" 602 | ] 603 | }, 604 | { 605 | "cell_type": "code", 606 | "execution_count": 37, 607 | "metadata": {}, 608 | "outputs": [ 609 | { 610 | "data": { 611 | "text/plain": [ 612 | "array([[ 0., 4., 1.],\n", 613 | " [ 7., 2., 12.]])" 614 | ] 615 | }, 616 | "execution_count": 37, 617 | "metadata": {}, 618 | "output_type": "execute_result" 619 | } 620 | ], 621 | "source": [ 622 | "arr2\n" 623 | ] 624 | }, 625 | { 626 | "cell_type": "code", 627 | "execution_count": 39, 628 | "metadata": {}, 629 | "outputs": [ 630 | { 631 | "data": { 632 | "text/plain": [ 633 | "array([[False, True, False],\n", 634 | " [ True, False, True]])" 635 | ] 636 | }, 637 | "execution_count": 39, 638 | "metadata": {}, 639 | "output_type": "execute_result" 640 | } 641 | ], 642 | "source": [ 643 | "arr = np.array([[1., 2., 3.], [4., 5., 6.]])\n", 644 | "\n", 645 | "arr2 > arr" 646 | ] 647 | }, 648 | { 649 | "cell_type": "code", 650 | "execution_count": null, 651 | "metadata": { 652 | "collapsed": true 653 | }, 654 | "outputs": [], 655 | "source": [] 656 | } 657 | ], 658 | "metadata": { 659 | "kernelspec": { 660 | "display_name": "Python 3", 661 | "language": "python", 662 | "name": "python3" 663 | }, 664 | "language_info": { 665 | "codemirror_mode": { 666 | "name": "ipython", 667 | "version": 3 668 | }, 669 | "file_extension": ".py", 670 | "mimetype": "text/x-python", 671 | "name": "python", 672 | "nbconvert_exporter": "python", 673 | "pygments_lexer": "ipython3", 674 | "version": "3.6.1" 675 | } 676 | }, 677 | "nbformat": 4, 678 | "nbformat_minor": 2 679 | } 680 | -------------------------------------------------------------------------------- /pricefromgooglefin.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "ename": "ModuleNotFoundError", 10 | "evalue": "No module named 'pandas_datareader'", 11 | "output_type": "error", 12 | "traceback": [ 13 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", 14 | "\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", 15 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mpandas_datareader\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mfix_yahoo_finance\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0myf\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0myf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpdr_override\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0msymbol\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m'AMZN'\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", 16 | "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'pandas_datareader'" 17 | ] 18 | } 19 | ], 20 | "source": [ 21 | "from pandas_datareader import data\n", 22 | "import fix_yahoo_finance as yf\n", 23 | "yf.pdr_override() \n", 24 | "\n", 25 | "symbol = 'AMZN'\n", 26 | "data_source='google'\n", 27 | "start_date = '2010-01-01'\n", 28 | "end_date = '2016-01-01'\n", 29 | "df = data.get_data_yahoo(symbol, start_date, end_date)\n", 30 | "\n", 31 | "df.head()" 32 | ] 33 | }, 34 | { 35 | "cell_type": "code", 36 | "execution_count": null, 37 | "metadata": {}, 38 | "outputs": [], 39 | "source": [] 40 | } 41 | ], 42 | "metadata": { 43 | "kernelspec": { 44 | "display_name": "Python 3.6", 45 | "language": "python", 46 | "name": "python36" 47 | }, 48 | "language_info": { 49 | "codemirror_mode": { 50 | "name": "ipython", 51 | "version": 3 52 | }, 53 | "file_extension": ".py", 54 | "mimetype": "text/x-python", 55 | "name": "python", 56 | "nbconvert_exporter": "python", 57 | "pygments_lexer": "ipython3", 58 | "version": "3.6.3" 59 | } 60 | }, 61 | "nbformat": 4, 62 | "nbformat_minor": 2 63 | } 64 | -------------------------------------------------------------------------------- /rawdata.txt: -------------------------------------------------------------------------------- 1 | hi this is first entry - col1 2 | i am 2nd line of first entry -col 3 | 4 | this is second - co1 5 | i am 2nd line of 2nd entyr -co2 6 | 7 | this is third - col1 8 | i am thir line of new tnryt - col2 -------------------------------------------------------------------------------- /readinglogfiles.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "data": { 10 | "text/plain": [ 11 | "['x', 'y', 'z']" 12 | ] 13 | }, 14 | "execution_count": 1, 15 | "metadata": {}, 16 | "output_type": "execute_result" 17 | } 18 | ], 19 | "source": [ 20 | "x=\"\"\"x\n", 21 | "\n", 22 | "y\n", 23 | "\n", 24 | "z\"\"\"\n", 25 | "#x.count('\\n\\n')\n", 26 | "x.split('\\n\\n')" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": null, 32 | "metadata": {}, 33 | "outputs": [], 34 | "source": [ 35 | "# reading from rawdata.txt" 36 | ] 37 | }, 38 | { 39 | "cell_type": "code", 40 | "execution_count": null, 41 | "metadata": {}, 42 | "outputs": [], 43 | "source": [] 44 | }, 45 | { 46 | "cell_type": "code", 47 | "execution_count": 23, 48 | "metadata": {}, 49 | "outputs": [], 50 | "source": [ 51 | "with open('rawdata.txt', 'r') as myfile:\n", 52 | " data = myfile.read()" 53 | ] 54 | }, 55 | { 56 | "cell_type": "code", 57 | "execution_count": 28, 58 | "metadata": {}, 59 | "outputs": [ 60 | { 61 | "data": { 62 | "text/plain": [ 63 | "'hi this is first entry - col1\\ni am 2nd line of first entry -col\\n\\nthis is second - co1\\ni am 2nd line of 2nd entyr -co2\\n\\nthis is third - col1\\ni am thir line of new tnryt - col2'" 64 | ] 65 | }, 66 | "execution_count": 28, 67 | "metadata": {}, 68 | "output_type": "execute_result" 69 | } 70 | ], 71 | "source": [ 72 | "data" 73 | ] 74 | }, 75 | { 76 | "cell_type": "code", 77 | "execution_count": 29, 78 | "metadata": {}, 79 | "outputs": [], 80 | "source": [ 81 | "mylist= data.split('\\n\\n')" 82 | ] 83 | }, 84 | { 85 | "cell_type": "code", 86 | "execution_count": 30, 87 | "metadata": {}, 88 | "outputs": [ 89 | { 90 | "data": { 91 | "text/plain": [ 92 | "['hi this is first entry - col1\\ni am 2nd line of first entry -col',\n", 93 | " 'this is second - co1\\ni am 2nd line of 2nd entyr -co2',\n", 94 | " 'this is third - col1\\ni am thir line of new tnryt - col2']" 95 | ] 96 | }, 97 | "execution_count": 30, 98 | "metadata": {}, 99 | "output_type": "execute_result" 100 | } 101 | ], 102 | "source": [ 103 | "mylist" 104 | ] 105 | }, 106 | { 107 | "cell_type": "code", 108 | "execution_count": 31, 109 | "metadata": {}, 110 | "outputs": [ 111 | { 112 | "data": { 113 | "text/plain": [ 114 | "['hi this is first entry - col1', 'i am 2nd line of first entry -col']" 115 | ] 116 | }, 117 | "execution_count": 31, 118 | "metadata": {}, 119 | "output_type": "execute_result" 120 | } 121 | ], 122 | "source": [ 123 | "mylist[0].split('\\n')" 124 | ] 125 | }, 126 | { 127 | "cell_type": "code", 128 | "execution_count": 34, 129 | "metadata": {}, 130 | "outputs": [ 131 | { 132 | "name": "stdout", 133 | "output_type": "stream", 134 | "text": [ 135 | "['hi this is first entry - col1', 'i am 2nd line of first entry -col']\n", 136 | "['this is second - co1', 'i am 2nd line of 2nd entyr -co2']\n", 137 | "['this is third - col1', 'i am thir line of new tnryt - col2']\n" 138 | ] 139 | } 140 | ], 141 | "source": [ 142 | "collist =[]\n", 143 | "for x in mylist:\n", 144 | " #mylist.append(x.split('\\n\\n'))\n", 145 | " print (x.split('\\n'))\n", 146 | " collist.append(x.split('\\n'))\n" 147 | ] 148 | }, 149 | { 150 | "cell_type": "code", 151 | "execution_count": 35, 152 | "metadata": {}, 153 | "outputs": [ 154 | { 155 | "data": { 156 | "text/plain": [ 157 | "[['hi this is first entry - col1', 'i am 2nd line of first entry -col'],\n", 158 | " ['this is second - co1', 'i am 2nd line of 2nd entyr -co2'],\n", 159 | " ['this is third - col1', 'i am thir line of new tnryt - col2']]" 160 | ] 161 | }, 162 | "execution_count": 35, 163 | "metadata": {}, 164 | "output_type": "execute_result" 165 | } 166 | ], 167 | "source": [ 168 | "collist" 169 | ] 170 | }, 171 | { 172 | "cell_type": "code", 173 | "execution_count": 37, 174 | "metadata": {}, 175 | "outputs": [ 176 | { 177 | "ename": "NameError", 178 | "evalue": "name 'pd' is not defined", 179 | "output_type": "error", 180 | "traceback": [ 181 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", 182 | "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", 183 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mtable\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcollist\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mdf\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mpd\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mDataFrame\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtable\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0mdf\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtranspose\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\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[0mcolumns\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m'Heading1'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'Heading2'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mdf\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", 184 | "\u001b[0;31mNameError\u001b[0m: name 'pd' is not defined" 185 | ] 186 | } 187 | ], 188 | "source": [ 189 | "table = collist\n", 190 | "df = pd.DataFrame(table)\n", 191 | "df = df.transpose()\n", 192 | "df.columns = ['Heading1', 'Heading2']\n", 193 | "df" 194 | ] 195 | }, 196 | { 197 | "cell_type": "code", 198 | "execution_count": null, 199 | "metadata": {}, 200 | "outputs": [], 201 | "source": [] 202 | } 203 | ], 204 | "metadata": { 205 | "kernelspec": { 206 | "display_name": "Python 3.6", 207 | "language": "python", 208 | "name": "python36" 209 | }, 210 | "language_info": { 211 | "codemirror_mode": { 212 | "name": "ipython", 213 | "version": 3 214 | }, 215 | "file_extension": ".py", 216 | "mimetype": "text/x-python", 217 | "name": "python", 218 | "nbconvert_exporter": "python", 219 | "pygments_lexer": "ipython3", 220 | "version": "3.6.3" 221 | } 222 | }, 223 | "nbformat": 4, 224 | "nbformat_minor": 2 225 | } 226 | --------------------------------------------------------------------------------