diff --git a/Student/lesson01/dance_party.ipynb b/Student/lesson01/dance_party.ipynb new file mode 100644 index 0000000..32d85be --- /dev/null +++ b/Student/lesson01/dance_party.ipynb @@ -0,0 +1,106 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "'''\n", + "Jay Johnson - Lesson01 - Assignment01 - Comprehensions\n", + "\n", + "Dance Party\n", + "////\n", + "v1.0 sorting isnt that efficent\n", + "need to add top 5 or 10\n", + "////\n", + "'''\n", + "\n", + "import pandas as pd\n", + "music = pd.read_csv(\"featuresdf.csv\")\n", + "\n", + "#music = sorted(music)\n", + "#print(music)\n", + "\n", + "music.head()\n", + "music.describe()\n", + "music.name\n", + "music.artists\n", + "music.loudness\n", + "\n", + "dance = [x for x in music.danceability if x > 0.8]\n", + "loud = [y for y in music.loudness if y < -5.0]\n", + "\n", + "#[x for x in music.danceability if x > 0.8]\n", + "#[y for y in music.loudness if y < -5.0]\n", + "#[y for y in music.loudness if y < -5.0]\n", + "\n", + "#both_of_them = [(x for x in music.danceability if x > 0.8) or (y for y in music.loudness if y < -5.0)]\n", + "\n", + "#print(both_of_them)\\\n", + "#print(dance)\n", + "#print(loud)\n", + "\n", + "loud = sorted(loud)\n", + "dance = sorted(dance)\n", + "\n", + "#music.query('music.danceability == dance | music.loudness == loud')\n", + "\n", + "#some_value = float(-6.769)\n", + "\n", + "# print from list[0]\n", + "loud_len = len(loud)\n", + "dance_len = len(dance)\n", + "\n", + "print(dance_len)\n", + "\n", + "#new_artist = music[music.loudness == loud[1]]\n", + "#print(new_artist.name)\n", + "#print(new_artist.artists)\n", + "\n", + "\n", + "# Your job, now, is to get artists and song names\n", + "# for for tracks with\n", + "# danceability scores over 0.8 and loudness scores below -5.0\n", + "for i in range(0, loud_len):\n", + " new_artist = music[music.loudness == loud[i]]\n", + " #print(new_artist.name)\n", + " #print(new_artist.artists)\n", + " # compare loop here\n", + " for i2 in range(0, dance_len):\n", + " new_artist_2 = music[music.danceability == dance[i2]]\n", + " #print(new_artist_2.name)\n", + " #print(new_artist_2.artists)\n", + " name1 = new_artist.name\n", + " name2 = new_artist_2.name\n", + " if str(name1) == str(name2):\n", + " print(new_artist.name)\n", + " print(new_artist.artists)\n", + " #else:\n", + " #print('nope')\n", + " i2=0\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.6.3" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/Student/lesson01/dance_party.py b/Student/lesson01/dance_party.py new file mode 100644 index 0000000..ddc7cdb --- /dev/null +++ b/Student/lesson01/dance_party.py @@ -0,0 +1,73 @@ +''' +Jay Johnson - Lesson01 - Assignment01 - Comprehensions + +Dance Party +//// +v1.0 sorting isnt that efficent +need to add top 5 or 10 +//// +''' + +import pandas as pd +music = pd.read_csv("featuresdf.csv") + +#music = sorted(music) +#print(music) + +music.head() +music.describe() +music.name +music.artists +music.loudness + +dance = [x for x in music.danceability if x > 0.8] +loud = [y for y in music.loudness if y < -5.0] + +#[x for x in music.danceability if x > 0.8] +#[y for y in music.loudness if y < -5.0] +#[y for y in music.loudness if y < -5.0] + +#both_of_them = [(x for x in music.danceability if x > 0.8) or (y for y in music.loudness if y < -5.0)] + +#print(both_of_them)\ +#print(dance) +#print(loud) + +loud = sorted(loud) +dance = sorted(dance) + +#music.query('music.danceability == dance | music.loudness == loud') + +#some_value = float(-6.769) + +# print from list[0] +loud_len = len(loud) +dance_len = len(dance) + +print(dance_len) + +#new_artist = music[music.loudness == loud[1]] +#print(new_artist.name) +#print(new_artist.artists) + + +# Your job, now, is to get artists and song names +# for for tracks with +# danceability scores over 0.8 and loudness scores below -5.0 +for i in range(0, loud_len): + new_artist = music[music.loudness == loud[i]] + #print(new_artist.name) + #print(new_artist.artists) + # compare loop here + for i2 in range(0, dance_len): + new_artist_2 = music[music.danceability == dance[i2]] + #print(new_artist_2.name) + #print(new_artist_2.artists) + name1 = new_artist.name + name2 = new_artist_2.name + if str(name1) == str(name2): + print(new_artist.name) + print(new_artist.artists) + #else: + #print('nope') + i2=0 diff --git a/Student/lesson01/featuresdf.csv b/Student/lesson01/featuresdf.csv new file mode 100644 index 0000000..ece51ea --- /dev/null +++ b/Student/lesson01/featuresdf.csv @@ -0,0 +1,101 @@ +id,name,artists,danceability,energy,key,loudness,mode,speechiness,acousticness,instrumentalness,liveness,valence,tempo,duration_ms,time_signature +7qiZfU4dY1lWllzX7mPBI,Shape of You,Ed Sheeran,0.825,0.652,1.0,-3.183,0.0,0.0802,0.581,0.0,0.0931,0.931,95.977,233713.0,4.0 +5CtI0qwDJkDQGwXD1H1cL,Despacito - Remix,Luis Fonsi,0.694,0.815,2.0,-4.328,1.0,0.12,0.229,0.0,0.0924,0.813,88.931,228827.0,4.0 +4aWmUDTfIPGksMNLV2rQP,Despacito (Featuring Daddy Yankee),Luis Fonsi,0.66,0.786,2.0,-4.757,1.0,0.17,0.209,0.0,0.112,0.846,177.833,228200.0,4.0 +6RUKPb4LETWmmr3iAEQkt,Something Just Like This,The Chainsmokers,0.617,0.635,11.0,-6.769,0.0,0.0317,0.0498,1.44e-05,0.164,0.446,103.019,247160.0,4.0 +3DXncPQOG4VBw3QHh3S81,I'm the One,DJ Khaled,0.609,0.668,7.0,-4.284,1.0,0.0367,0.0552,0.0,0.167,0.811,80.924,288600.0,4.0 +7KXjTSCq5nL1LoYtL7XAw,HUMBLE.,Kendrick Lamar,0.904,0.611,1.0,-6.842,0.0,0.0888,0.000259,2.03e-05,0.0976,0.4,150.02,177000.0,4.0 +3eR23VReFzcdmS7TYCrhC,It Ain't Me (with Selena Gomez),Kygo,0.64,0.533,0.0,-6.596,1.0,0.0706,0.119,0.0,0.0864,0.515,99.968,220781.0,4.0 +3B54sVLJ402zGa6Xm4YGN,Unforgettable,French Montana,0.726,0.769,6.0,-5.043,1.0,0.123,0.0293,0.0101,0.104,0.733,97.985,233902.0,4.0 +0KKkJNfGyhkQ5aFogxQAP,That's What I Like,Bruno Mars,0.853,0.56,1.0,-4.961,1.0,0.0406,0.013,0.0,0.0944,0.86,134.066,206693.0,4.0 +3NdDpSvN911VPGivFlV5d,"I Don’t Wanna Live Forever (Fifty Shades Darker) - From ""Fifty Shades Darker (Original Motion Picture Soundtrack)""",ZAYN,0.735,0.451,0.0,-8.374,1.0,0.0585,0.0631,1.3e-05,0.325,0.0862,117.973,245200.0,4.0 +7GX5flRQZVHRAGd6B4TmD,XO TOUR Llif3,Lil Uzi Vert,0.732,0.75,11.0,-6.366,0.0,0.231,0.00264,0.0,0.109,0.401,155.096,182707.0,4.0 +72jbDTw1piOOj770jWNea,Paris,The Chainsmokers,0.653,0.658,2.0,-6.428,1.0,0.0304,0.0215,1.66e-06,0.0939,0.219,99.99,221507.0,4.0 +0dA2Mk56wEzDgegdC6R17,Stay (with Alessia Cara),Zedd,0.679,0.634,5.0,-5.024,0.0,0.0654,0.232,0.0,0.115,0.498,102.013,210091.0,4.0 +4iLqG9SeJSnt0cSPICSjx,Attention,Charlie Puth,0.774,0.626,3.0,-4.432,0.0,0.0432,0.0969,3.12e-05,0.0848,0.777,100.041,211475.0,4.0 +0VgkVdmE4gld66l8iyGjg,Mask Off,Future,0.833,0.434,2.0,-8.795,1.0,0.431,0.0102,0.0219,0.165,0.281,150.062,204600.0,4.0 +3a1lNhkSLSkpJE4MSHpDu,Congratulations,Post Malone,0.627,0.812,6.0,-4.215,1.0,0.0358,0.198,0.0,0.212,0.504,123.071,220293.0,4.0 +6kex4EBAj0WHXDKZMEJaa,Swalla (feat. Nicki Minaj & Ty Dolla $ign),Jason Derulo,0.696,0.817,1.0,-3.862,1.0,0.109,0.075,0.0,0.187,0.782,98.064,216409.0,4.0 +6PCUP3dWmTjcTtXY02oFd,Castle on the Hill,Ed Sheeran,0.461,0.834,2.0,-4.868,1.0,0.0989,0.0232,1.14e-05,0.14,0.471,135.007,261154.0,4.0 +5knuzwU65gJK7IF5yJsua,Rockabye (feat. Sean Paul & Anne-Marie),Clean Bandit,0.72,0.763,9.0,-4.068,0.0,0.0523,0.406,0.0,0.18,0.742,101.965,251088.0,4.0 +0CcQNd8CINkwQfe1RDtGV,Believer,Imagine Dragons,0.779,0.787,10.0,-4.305,0.0,0.108,0.0524,0.0,0.14,0.708,124.982,204347.0,4.0 +2rb5MvYT7ZIxbKW5hfcHx,Mi Gente,J Balvin,0.543,0.677,11.0,-4.915,0.0,0.0993,0.0148,6.21e-06,0.13,0.294,103.809,189440.0,4.0 +0tKcYR2II1VCQWT79i5Nr,Thunder,Imagine Dragons,0.6,0.81,0.0,-4.749,1.0,0.0479,0.00683,0.21,0.155,0.298,167.88,187147.0,4.0 +5uCax9HTNlzGybIStD3vD,Say You Won't Let Go,James Arthur,0.358,0.557,10.0,-7.398,1.0,0.059,0.695,0.0,0.0902,0.494,85.043,211467.0,4.0 +79cuOz3SPQTuFrp8WgftA,There's Nothing Holdin' Me Back,Shawn Mendes,0.857,0.8,2.0,-4.035,1.0,0.0583,0.381,0.0,0.0913,0.966,121.996,199440.0,4.0 +6De0lHrwBfPfrhorm9q1X,Me Rehúso,Danny Ocean,0.744,0.804,1.0,-6.327,1.0,0.0677,0.0231,0.0,0.0494,0.426,104.823,205715.0,4.0 +6D0b04NJIKfEMg040WioJ,Issues,Julia Michaels,0.706,0.427,8.0,-6.864,1.0,0.0879,0.413,0.0,0.0609,0.42,113.804,176320.0,4.0 +0afhq8XCExXpqazXczTSv,Galway Girl,Ed Sheeran,0.624,0.876,9.0,-3.374,1.0,0.1,0.0735,0.0,0.327,0.781,99.943,170827.0,4.0 +3ebXMykcMXOcLeJ9xZ17X,Scared to Be Lonely,Martin Garrix,0.584,0.54,1.0,-7.786,0.0,0.0576,0.0895,0.0,0.261,0.195,137.972,220883.0,4.0 +7BKLCZ1jbUBVqRi2FVlTV,Closer,The Chainsmokers,0.748,0.524,8.0,-5.599,1.0,0.0338,0.414,0.0,0.111,0.661,95.01,244960.0,4.0 +1x5sYLZiu9r5E43kMlt9f,Symphony (feat. Zara Larsson),Clean Bandit,0.707,0.629,0.0,-4.581,0.0,0.0563,0.259,1.6e-05,0.138,0.457,122.863,212459.0,4.0 +5GXAXm5YOmYT0kL5jHvYB,I Feel It Coming,The Weeknd,0.768,0.813,0.0,-5.94,0.0,0.128,0.427,0.0,0.102,0.579,92.994,269187.0,4.0 +5aAx2yezTd8zXrkmtKl66,Starboy,The Weeknd,0.681,0.594,7.0,-7.028,1.0,0.282,0.165,3.49e-06,0.134,0.535,186.054,230453.0,4.0 +1OAh8uOEOvTDqkKFsKksC,Wild Thoughts,DJ Khaled,0.671,0.672,0.0,-3.094,0.0,0.0688,0.0329,0.0,0.118,0.632,97.98,204173.0,4.0 +7tr2za8SQg2CI8EDgrdtN,Slide,Calvin Harris,0.736,0.795,1.0,-3.299,0.0,0.0545,0.498,1.21e-06,0.254,0.511,104.066,230813.0,4.0 +2ekn2ttSfGqwhhate0LSR,New Rules,Dua Lipa,0.771,0.696,9.0,-6.258,0.0,0.0755,0.00256,9.71e-06,0.179,0.656,116.054,208827.0,4.0 +5tz69p7tJuGPeMGwNTxYu,1-800-273-8255,Logic,0.629,0.572,5.0,-7.733,0.0,0.0387,0.57,0.0,0.192,0.386,100.015,250173.0,4.0 +7hDc8b7IXETo14hHIHdnh,Passionfruit,Drake,0.809,0.463,11.0,-11.377,1.0,0.0396,0.256,0.085,0.109,0.364,111.98,298941.0,4.0 +7wGoVu4Dady5GV0Sv4UIs,rockstar,Post Malone,0.577,0.522,5.0,-6.594,0.0,0.0984,0.13,9.03e-05,0.142,0.119,159.772,218320.0,4.0 +6EpRaXYhGOB3fj4V2uDkM,Strip That Down,Liam Payne,0.869,0.485,6.0,-5.595,1.0,0.0545,0.246,0.0,0.0765,0.527,106.028,204502.0,4.0 +3A7qX2QjDlPnazUsRk5y0,2U (feat. Justin Bieber),David Guetta,0.548,0.65,8.0,-5.827,0.0,0.0591,0.219,0.0,0.225,0.557,144.937,194897.0,4.0 +0tgVpDi06FyKpA1z0VMD4,Perfect,Ed Sheeran,0.599,0.448,8.0,-6.312,1.0,0.0232,0.163,0.0,0.106,0.168,95.05,263400.0,3.0 +78rIJddV4X0HkNAInEcYd,Call On Me - Ryan Riback Extended Remix,Starley,0.676,0.843,0.0,-4.068,1.0,0.0367,0.0623,0.000752,0.181,0.718,105.003,222041.0,4.0 +5bcTCxgc7xVfSaMV3RuVk,Feels,Calvin Harris,0.893,0.745,11.0,-3.105,0.0,0.0571,0.0642,0.0,0.0943,0.872,101.018,223413.0,4.0 +0NiXXAI876aGImAd6rTj8,Mama,Jonas Blue,0.746,0.793,11.0,-4.209,0.0,0.0412,0.11,0.0,0.0528,0.557,104.027,181615.0,4.0 +0qYTZCo5Bwh1nsUFGZP3z,Felices los 4,Maluma,0.755,0.789,5.0,-4.502,1.0,0.146,0.231,0.0,0.351,0.737,93.973,229849.0,4.0 +2EEeOnHehOozLq4aS0n6S,iSpy (feat. Lil Yachty),KYLE,0.746,0.653,7.0,-6.745,1.0,0.289,0.378,0.0,0.229,0.672,75.016,253107.0,4.0 +152lZdxL1OR0ZMW6KquMi,Location,Khalid,0.736,0.449,1.0,-11.462,0.0,0.425,0.33,0.000162,0.0898,0.326,80.126,219080.0,4.0 +6mICuAdrwEjh6Y6lroV2K,Chantaje,Shakira,0.852,0.773,8.0,-2.921,0.0,0.0776,0.187,3.05e-05,0.159,0.907,102.034,195840.0,4.0 +4Km5HrUvYTaSUfiSGPJeQ,Bad and Boujee (feat. Lil Uzi Vert),Migos,0.927,0.665,11.0,-5.313,1.0,0.244,0.061,0.0,0.123,0.175,127.076,343150.0,4.0 +0ofbQMrRDsUaVKq2mGLEA,Havana,Camila Cabello,0.768,0.517,7.0,-4.323,0.0,0.0312,0.186,3.8e-05,0.104,0.418,104.992,216897.0,4.0 +6HUnnBwYZqcED1eQztxMB,Solo Dance,Martin Jensen,0.744,0.836,6.0,-2.396,0.0,0.0507,0.0435,0.0,0.194,0.36,114.965,174933.0,4.0 +343YBumqHu19cGoGARUTs,Fake Love,Drake,0.927,0.488,9.0,-9.433,0.0,0.42,0.108,0.0,0.196,0.605,133.987,210937.0,4.0 +4pdPtRcBmOSQDlJ3Fk945,Let Me Love You,DJ Snake,0.476,0.718,8.0,-5.309,1.0,0.0576,0.0784,1.02e-05,0.122,0.142,199.864,205947.0,4.0 +3PEgB3fkiojxms35ntsTg,More Than You Know,Axwell /\ Ingrosso,0.644,0.743,5.0,-5.002,0.0,0.0355,0.034,0.0,0.257,0.544,123.074,203000.0,4.0 +1xznGGDReH1oQq0xzbwXa,One Dance,Drake,0.791,0.619,1.0,-5.886,1.0,0.0532,0.00784,0.00423,0.351,0.371,103.989,173987.0,4.0 +7nKBxz47S9SD79N086fuh,SUBEME LA RADIO,Enrique Iglesias,0.684,0.823,9.0,-3.297,0.0,0.0773,0.0744,0.0,0.111,0.647,91.048,208163.0,4.0 +1NDxZ7cFAo481dtYWdrUn,Pretty Girl - Cheat Codes X CADE Remix,Maggie Lindemann,0.703,0.868,7.0,-4.661,0.0,0.0291,0.15,0.132,0.104,0.733,121.03,193613.0,4.0 +3m660poUr1chesgkkjQM7,Sorry Not Sorry,Demi Lovato,0.704,0.633,11.0,-6.923,0.0,0.241,0.0214,0.0,0.29,0.863,144.021,203760.0,4.0 +3kxfsdsCpFgN412fpnW85,Redbone,Childish Gambino,0.743,0.359,1.0,-10.401,1.0,0.0794,0.199,0.00611,0.137,0.587,160.083,326933.0,4.0 +6b8Be6ljOzmkOmFslEb23,24K Magic,Bruno Mars,0.818,0.803,1.0,-4.282,1.0,0.0797,0.034,0.0,0.153,0.632,106.97,225983.0,4.0 +6HZILIRieu8S0iqY8kIKh,DNA.,Kendrick Lamar,0.637,0.514,1.0,-6.763,1.0,0.365,0.0047,0.0,0.094,0.402,139.931,185947.0,4.0 +3umS4y3uQDkqekNjVpiRU,El Amante,Nicky Jam,0.683,0.691,8.0,-5.535,1.0,0.0432,0.243,0.0,0.14,0.732,179.91,219507.0,4.0 +00lNx0OcTJrS3MKHcB80H,You Don't Know Me - Radio Edit,Jax Jones,0.876,0.669,11.0,-6.054,0.0,0.138,0.163,0.0,0.185,0.682,124.007,213947.0,4.0 +6520aj0B4FSKGVuKNsOCO,Chained To The Rhythm,Katy Perry,0.448,0.801,0.0,-5.363,1.0,0.165,0.0733,0.0,0.146,0.462,189.798,237734.0,4.0 +1louJpMmzEicAn7lzDalP,No Promises (feat. Demi Lovato),Cheat Codes,0.741,0.667,10.0,-5.445,1.0,0.134,0.0575,0.0,0.106,0.595,112.956,223504.0,4.0 +2QbFClFyhMMtiurUjuQlA,Don't Wanna Know (feat. Kendrick Lamar),Maroon 5,0.775,0.617,7.0,-6.166,1.0,0.0701,0.341,0.0,0.0985,0.485,100.048,214265.0,4.0 +5hYTyyh2odQKphUbMqc5g,"How Far I'll Go - From ""Moana""",Alessia Cara,0.314,0.555,9.0,-9.601,1.0,0.37,0.157,0.000108,0.067,0.159,179.666,175517.0,4.0 +38yBBH2jacvDxrznF7h08,Slow Hands,Niall Horan,0.734,0.418,0.0,-6.678,1.0,0.0425,0.0129,0.0,0.0579,0.868,85.909,188174.0,4.0 +2cnKEkpVUSV4wnjQiTWfH,Escápate Conmigo,Wisin,0.747,0.864,8.0,-3.181,0.0,0.0599,0.0245,4.46e-05,0.0853,0.754,92.028,232787.0,4.0 +0SGkqnVQo9KPytSri1H6c,Bounce Back,Big Sean,0.77,0.567,2.0,-5.698,1.0,0.175,0.105,0.0,0.125,0.26,81.477,222360.0,4.0 +5Ohxk2dO5COHF1krpoPig,Sign of the Times,Harry Styles,0.516,0.595,5.0,-4.63,1.0,0.0313,0.0275,0.0,0.109,0.222,119.972,340707.0,4.0 +6gBFPUFcJLzWGx4lenP6h,goosebumps,Travis Scott,0.841,0.728,7.0,-3.37,1.0,0.0484,0.0847,0.0,0.149,0.43,130.049,243837.0,4.0 +5Z3GHaZ6ec9bsiI5Benrb,Young Dumb & Broke,Khalid,0.798,0.539,1.0,-6.351,1.0,0.0421,0.199,1.66e-05,0.165,0.394,136.949,202547.0,4.0 +6jA8HL9i4QGzsj6fjoxp8,There for You,Martin Garrix,0.611,0.644,6.0,-7.607,0.0,0.0553,0.124,0.0,0.124,0.13,105.969,221904.0,4.0 +21TdkDRXuAB3k90ujRU1e,Cold (feat. Future),Maroon 5,0.697,0.716,9.0,-6.288,0.0,0.113,0.118,0.0,0.0424,0.506,99.905,234308.0,4.0 +7vGuf3Y35N4wmASOKLUVV,Silence,Marshmello,0.52,0.761,4.0,-3.093,1.0,0.0853,0.256,4.96e-06,0.17,0.286,141.971,180823.0,4.0 +1mXVgsBdtIVeCLJnSnmtd,Too Good At Goodbyes,Sam Smith,0.698,0.375,5.0,-8.279,1.0,0.0491,0.652,0.0,0.173,0.534,91.92,201000.0,4.0 +3EmmCZoqpWOTY1g2GBwJo,Just Hold On,Steve Aoki,0.647,0.932,11.0,-3.515,1.0,0.0824,0.00383,1.5e-06,0.0574,0.374,114.991,198774.0,4.0 +6uFsE1JgZ20EXyU0JQZbU,Look What You Made Me Do,Taylor Swift,0.773,0.68,9.0,-6.378,0.0,0.141,0.213,1.57e-05,0.122,0.497,128.062,211859.0,4.0 +0CokSRCu5hZgPxcZBaEzV,Glorious (feat. Skylar Grey),Macklemore,0.731,0.794,0.0,-5.126,0.0,0.0522,0.0323,2.59e-05,0.112,0.356,139.994,220454.0,4.0 +6875MeXyCW0wLyT72Eetm,Starving,Hailee Steinfeld,0.721,0.626,4.0,-4.2,1.0,0.123,0.402,0.0,0.102,0.558,99.914,181933.0,4.0 +3AEZUABDXNtecAOSC1qTf,Reggaetón Lento (Bailemos),CNCO,0.761,0.838,4.0,-3.073,0.0,0.0502,0.4,0.0,0.176,0.71,93.974,222560.0,4.0 +3E2Zh20GDCR9B1EYjfXWy,Weak,AJR,0.673,0.637,5.0,-4.518,1.0,0.0429,0.137,0.0,0.184,0.678,123.98,201160.0,4.0 +4pLwZjInHj3SimIyN9SnO,Side To Side,Ariana Grande,0.648,0.738,6.0,-5.883,0.0,0.247,0.0408,0.0,0.292,0.603,159.145,226160.0,4.0 +3QwBODjSEzelZyVjxPOHd,Otra Vez (feat. J Balvin),Zion & Lennox,0.832,0.772,10.0,-5.429,1.0,0.1,0.0559,0.000486,0.44,0.704,96.016,209453.0,4.0 +1wjzFQodRWrPcQ0AnYnvQ,I Like Me Better,Lauv,0.752,0.505,9.0,-7.621,1.0,0.253,0.535,2.55e-06,0.104,0.419,91.97,197437.0,4.0 +04DwTuZ2VBdJCCC5TROn7,In the Name of Love,Martin Garrix,0.49,0.485,4.0,-6.237,0.0,0.0406,0.0592,0.0,0.337,0.196,133.889,195840.0,4.0 +6DNtNfH8hXkqOX1sjqmI7,Cold Water (feat. Justin Bieber & MØ),Major Lazer,0.608,0.798,6.0,-5.092,0.0,0.0432,0.0736,0.0,0.156,0.501,92.943,185352.0,4.0 +1UZOjK1BwmwWU14Erba9C,Malibu,Miley Cyrus,0.573,0.781,8.0,-6.406,1.0,0.0555,0.0767,2.64e-05,0.0813,0.343,139.934,231907.0,4.0 +4b4KcovePX8Ke2cLIQTLM,All Night,The Vamps,0.544,0.809,8.0,-5.098,1.0,0.0363,0.0038,0.0,0.323,0.448,145.017,197640.0,4.0 +1a5Yu5L18qNxVhXx38njO,Hear Me Now,Alok,0.789,0.442,11.0,-7.844,1.0,0.0421,0.586,0.00366,0.0927,0.45,121.971,192846.0,4.0 +4c2W3VKsOFoIg2SFaO6DY,Your Song,Rita Ora,0.855,0.624,1.0,-4.093,1.0,0.0488,0.158,0.0,0.0513,0.962,117.959,180757.0,4.0 +22eADXu8DfOAUEDw4vU8q,Ahora Dice,Chris Jeday,0.708,0.693,6.0,-5.516,1.0,0.138,0.246,0.0,0.129,0.427,143.965,271080.0,4.0 +7nZmah2llfvLDiUjm0kiy,Friends (with BloodPop®),Justin Bieber,0.744,0.739,8.0,-5.35,1.0,0.0387,0.00459,0.0,0.306,0.649,104.99,189467.0,4.0 +2fQrGHiQOvpL9UgPvtYy6,Bank Account,21 Savage,0.884,0.346,8.0,-8.228,0.0,0.351,0.0151,7.04e-06,0.0871,0.376,75.016,220307.0,4.0 +1PSBzsahR2AKwLJgx8ehB,Bad Things (with Camila Cabello),Machine Gun Kelly,0.675,0.69,2.0,-4.761,1.0,0.132,0.21,0.0,0.287,0.272,137.817,239293.0,4.0 +0QsvXIfqM0zZoerQfsI9l,Don't Let Me Down,The Chainsmokers,0.542,0.859,11.0,-5.651,1.0,0.197,0.16,0.00466,0.137,0.403,159.797,208053.0,4.0 +7mldq42yDuxiUNn08nvzH,Body Like A Back Road,Sam Hunt,0.731,0.469,5.0,-7.226,1.0,0.0326,0.463,1.04e-06,0.103,0.631,98.963,165387.0,4.0 +7i2DJ88J7jQ8K7zqFX2fW,Now Or Never,Halsey,0.658,0.588,6.0,-4.902,0.0,0.0367,0.105,1.28e-06,0.125,0.434,110.075,214802.0,4.0 +1j4kHkkpqZRBwE0A4CN4Y,Dusk Till Dawn - Radio Edit,ZAYN,0.258,0.437,11.0,-6.593,0.0,0.039,0.101,1.27e-06,0.106,0.0967,180.043,239000.0,4.0 diff --git a/Student/lesson01/generator.ipynb b/Student/lesson01/generator.ipynb new file mode 100644 index 0000000..750a2a0 --- /dev/null +++ b/Student/lesson01/generator.ipynb @@ -0,0 +1,155 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0\n", + "1\n", + "3\n", + "6\n", + "10\n", + "15\n", + "21\n", + "28\n", + "36\n", + "45\n", + "55\n", + "\n", + " break \n", + "\n", + "0\n", + "1\n", + "2\n", + "4\n", + "8\n", + "16\n", + "32\n", + "\n", + " break \n", + "\n", + "0\n", + "1\n", + "1\n", + "2\n", + "3\n", + "5\n", + "8\n", + "13\n", + "21\n", + "34\n", + "\n", + " break \n", + "\n", + "[2, 3, 5, 7, 11, 13, 17, 19, 23]\n" + ] + } + ], + "source": [ + "'''\n", + "Jay Johnson - Lesson01 - Activity01 - Generators\n", + "'''\n", + "import math\n", + "### generator ####\n", + "\n", + "#0, 1, 3, 6, 10, 15\n", + "# Sum of the integers\n", + "def sum_range(start, stop, step=1):\n", + " i = start\n", + " k = 1\n", + " print(i)\n", + " while i < stop:\n", + " yield i + k\n", + " i += step\n", + " k = i + k\n", + "\n", + "# Doubler 1, 2, 4, 8, 16, 32,\n", + "def y_range(start, stop, step=1):\n", + " i = start\n", + " while i < stop:\n", + " yield i\n", + " i += i\n", + " i += step\n", + " step = 0\n", + "\n", + "\n", + "# Fibonacci sequence\n", + "def fibonacci(max):\n", + " a, b = 0, 1\n", + " while a < max:\n", + " yield a\n", + " a, b = b, a+b\n", + "\n", + "\n", + "# Prime numbers\n", + "def prime():\n", + " noprimes = [j for i in range(2, 8) for j in range(i*2, 24, i)]\n", + " primes = [x for x in range(2, 24) if x not in noprimes]\n", + " print(primes)\n", + "\n", + "\n", + "if __name__ == '__main__':\n", + "\n", + " sum_number = sum_range(0, 10, step=1)\n", + "\n", + " #gernerator for sum of ints\n", + " for s_number in sum_number:\n", + " print(s_number)\n", + "\n", + " print('\\n break \\n')\n", + "\n", + " y_ranger = y_range(0, 33, step=1)\n", + "\n", + " # generator for doubler\n", + " for y_number in y_ranger:\n", + " print(y_number)\n", + "\n", + " print('\\n break \\n')\n", + "\n", + " # generator of fibonacci numbers\n", + " fibonacci_generator = fibonacci(35)\n", + "\n", + " # print out the fibonacci numbers\n", + " for fibonacci_number in fibonacci_generator:\n", + " print(fibonacci_number)\n", + "\n", + " print('\\n break \\n')\n", + "\n", + " prime()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.6.3" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/Student/lesson01/generator.py b/Student/lesson01/generator.py new file mode 100644 index 0000000..e50eb20 --- /dev/null +++ b/Student/lesson01/generator.py @@ -0,0 +1,70 @@ +''' +Jay Johnson - Lesson01 - Activity01 - Generators +''' +import math +### generator #### + +#0, 1, 3, 6, 10, 15 +# Sum of the integers +def sum_range(start, stop, step=1): + i = start + k = 1 + print(i) + while i < stop: + yield i + k + i += step + k = i + k + +# Doubler 1, 2, 4, 8, 16, 32, +def y_range(start, stop, step=1): + i = start + while i < stop: + yield i + i += i + i += step + step = 0 + + +# Fibonacci sequence +def fibonacci(max): + a, b = 0, 1 + while a < max: + yield a + a, b = b, a+b + + +# Prime numbers +def prime(): + noprimes = [j for i in range(2, 8) for j in range(i*2, 24, i)] + primes = [x for x in range(2, 24) if x not in noprimes] + print(primes) + + +if __name__ == '__main__': + + sum_number = sum_range(0, 10, step=1) + + #gernerator for sum of ints + for s_number in sum_number: + print(s_number) + + print('\n break \n') + + y_ranger = y_range(0, 33, step=1) + + # generator for doubler + for y_number in y_ranger: + print(y_number) + + print('\n break \n') + + # generator of fibonacci numbers + fibonacci_generator = fibonacci(35) + + # print out the fibonacci numbers + for fibonacci_number in fibonacci_generator: + print(fibonacci_number) + + print('\n break \n') + + prime() diff --git a/Student/lesson01/iterable_1.ipynb b/Student/lesson01/iterable_1.ipynb new file mode 100644 index 0000000..14dd408 --- /dev/null +++ b/Student/lesson01/iterable_1.ipynb @@ -0,0 +1,67 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[2, 4, 6, 8, 10, 12, 14, 16, 18]\n", + "[2, 4, 6, 8, 10, 12, 14, 16, 18]\n" + ] + } + ], + "source": [ + "'''\n", + "Jay Johnson - Lesson01 - Activity01 - Iterators & Iteratables\n", + "iteraable_1\n", + "'''\n", + "\n", + "\n", + "def frange(start, stop, step=1):\n", + " '''match range()'''\n", + " i = start\n", + " while i < stop:\n", + " yield i\n", + " i += step\n", + "\n", + "print(list(frange(2,20,2)))\n", + "print(list(range(2,20,2)))\n", + "\n", + "#for i in range(2, 20, 2):\n", + " #print(i)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.6.3" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/Student/lesson01/iterable_1.py b/Student/lesson01/iterable_1.py new file mode 100644 index 0000000..c7b2dc4 --- /dev/null +++ b/Student/lesson01/iterable_1.py @@ -0,0 +1,18 @@ +''' +Jay Johnson - Lesson01 - Activity01 - Iterators & Iteratables +iterator_1 +''' + + +def frange(start, stop, step=1): + '''match range()''' + i = start + while i < stop: + yield i + i += step + +print(list(frange(2,20,2))) +print(list(range(2,20,2))) + +#for i in range(2, 20, 2): + #print(i) diff --git a/Student/lesson02/Dancing_Ed.ipynb b/Student/lesson02/Dancing_Ed.ipynb new file mode 100644 index 0000000..d358563 --- /dev/null +++ b/Student/lesson02/Dancing_Ed.ipynb @@ -0,0 +1,217 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Ed Sheeran finder\n", + "\n", + "Shape of You\n", + "Castle on the Hill\n", + "Galway Girl\n", + "Perfect\n", + "\n", + "Energy finder\n", + "\n", + "Despacito - Remix\n", + "Luis Fonsi\n", + "0.815\n", + "Congratulations\n", + "Post Malone\n", + "0.812\n", + "Swalla (feat. Nicki Minaj & Ty Dolla $ign)\n", + "Jason Derulo\n", + "0.8170000000000001\n", + "Castle on the Hill\n", + "Ed Sheeran\n", + "0.8340000000000001\n", + "Thunder\n", + "Imagine Dragons\n", + "0.81\n", + "There's Nothing Holdin' Me Back\n", + "Shawn Mendes\n", + "0.8\n", + "Me Rehúso\n", + "Danny Ocean\n", + "0.804\n", + "Galway Girl\n", + "Ed Sheeran\n", + "0.8759999999999999\n", + "I Feel It Coming\n", + "The Weeknd\n", + "0.813\n", + "Call On Me - Ryan Riback Extended Remix\n", + "Starley\n", + "0.843\n", + "Solo Dance\n", + "Martin Jensen\n", + "0.836\n", + "SUBEME LA RADIO\n", + "Enrique Iglesias\n", + "0.823\n", + "Pretty Girl - Cheat Codes X CADE Remix\n", + "Maggie Lindemann\n", + "0.868\n", + "24K Magic\n", + "Bruno Mars\n", + "0.8029999999999999\n", + "Chained To The Rhythm\n", + "Katy Perry\n", + "0.8009999999999999\n", + "Escápate Conmigo\n", + "Wisin\n", + "0.8640000000000001\n", + "Just Hold On\n", + "Steve Aoki\n", + "0.932\n", + "Reggaetón Lento (Bailemos)\n", + "CNCO\n", + "0.838\n", + "All Night\n", + "The Vamps\n", + "0.809\n", + "Don't Let Me Down\n", + "The Chainsmokers\n", + "0.8590000000000001\n" + ] + } + ], + "source": [ + "'''\n", + "Jay Johnson - Lesson02 - Assignment02 - Generators and Closures\n", + "\n", + "Ed Sheeran song lister with generators and closures\n", + "--\n", + "Write a generator to find and print all of your favorite artist’s\n", + "tracks from the data set. Your favorite artist isn’t represented\n", + "in that set? In that case, find Ed Sheeran’s tracks.\n", + "\n", + "Find Ed Sheeran’s tracks - DONE\n", + "\n", + "----\n", + "Closures\n", + "Using the same data set, write a closure to capture\n", + "high energy tracks. We will define high energy tracks\n", + "as anything over 8.0. Submit your code and the tracks it finds,\n", + "artist name, track name and energy value.\n", + "\n", + "8.0 or higher energy finder - DONE\n", + "\n", + "'''\n", + "import pandas as pd\n", + "music = pd.read_csv(\"featuresdf.csv\")\n", + "\n", + "#print(name.name)\n", + "full_list = len(music.name)\n", + "#print(full_list)\n", + "\n", + "# generator to find and print all of your favorite artist’s\n", + "# tracks from the data set.\n", + "def ed_sheeran_gen(start, stop):\n", + " music = pd.read_csv(\"featuresdf.csv\")\n", + " i = start\n", + " while i < stop:\n", + " new_song= music.name[i]\n", + " #print(new_song)\n", + " #print(music.artists[i])\n", + " if music.artists[i] == 'Ed Sheeran':\n", + " yield music.name[i]#new_song\n", + " i += 1\n", + " \n", + "def counter():\n", + " music = pd.read_csv(\"featuresdf.csv\")\n", + " count = 0\n", + " def increment():\n", + " nonlocal count\n", + " if music.energy[count] >= 0.8:\n", + " print(music.name[count])\n", + " print(music.artists[count])\n", + " print(music.energy[count])\n", + " count += 1\n", + " return count\n", + " return increment\n", + "\n", + "# write a closure to capture high energy tracks. \n", + "# we will define high energy tracksas anything over 8.0.\n", + "if __name__ == '__main__':\n", + " \n", + " print(\"Ed Sheeran finder\\n\")\n", + "\n", + " ed_gen = ed_sheeran_gen(0,full_list)\n", + " \n", + " for ed_gen_x in ed_gen:\n", + " print(ed_gen_x)\n", + " \n", + " print(\"\\nEnergy finder\\n\")\n", + " \n", + " my_counter = counter()\n", + " \n", + " for j in range(0,full_list):\n", + " my_counter()\n", + " \n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.6.3" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/Student/lesson02/Dancing_Ed.py b/Student/lesson02/Dancing_Ed.py new file mode 100644 index 0000000..0b732e0 --- /dev/null +++ b/Student/lesson02/Dancing_Ed.py @@ -0,0 +1,71 @@ +''' +Jay Johnson - Lesson02 - Assignment02 - Generators and Closures + +Ed Sheeran song lister with generators and closures +-- +Write a generator to find and print all of your favorite artist’s +tracks from the data set. Your favorite artist isn’t represented +in that set? In that case, find Ed Sheeran’s tracks. + +Find Ed Sheeran’s tracks - DONE + +---- +Closures +Using the same data set, write a closure to capture +high energy tracks. We will define high energy tracks +as anything over 8.0. Submit your code and the tracks it finds, +artist name, track name and energy value. + +8.0 or higher energy finder - DONE + +''' +import pandas as pd +music = pd.read_csv("featuresdf.csv") + +#print(name.name) +full_list = len(music.name) +#print(full_list) + +# generator to find and print all of your favorite artist’s +# tracks from the data set. +def ed_sheeran_gen(start, stop): + music = pd.read_csv("featuresdf.csv") + i = start + while i < stop: + new_song= music.name[i] + #print(new_song) + #print(music.artists[i]) + if music.artists[i] == 'Ed Sheeran': + yield music.name[i]#new_song + i += 1 + +def counter(): + music = pd.read_csv("featuresdf.csv") + count = 0 + def increment(): + nonlocal count + if music.energy[count] >= 0.8: + print(music.name[count]) + print(music.artists[count]) + print(music.energy[count]) + count += 1 + return count + return increment + +# write a closure to capture high energy tracks. +# we will define high energy tracksas anything over 8.0. +if __name__ == '__main__': + + print("Ed Sheeran finder\n") + + ed_gen = ed_sheeran_gen(0,full_list) + + for ed_gen_x in ed_gen: + print(ed_gen_x) + + print("\nEnergy finder\n") + + my_counter = counter() + + for j in range(0,full_list): + my_counter()