Skip to content

Commit

Permalink
worksheet3 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
katieburak committed Jul 3, 2024
1 parent 577184e commit 5ef4896
Show file tree
Hide file tree
Showing 8 changed files with 1,894 additions and 1,658 deletions.
Binary file modified .DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"data":{"layout-restorer:data":{"main":{"dock":{"type":"tab-area","currentIndex":0,"widgets":[]}},"down":{"size":0,"widgets":[]},"left":{"collapsed":false,"current":"filebrowser","widgets":["filebrowser","running-sessions","@jupyterlab/toc:plugin","extensionmanager.main-view"]},"right":{"collapsed":true,"widgets":["jp-property-inspector","debugger-sidebar"]},"relativeSizes":[0.21566265060240963,0.7843373493975904,0]},"file-browser-filebrowser:cwd":{"path":""}},"metadata":{"id":"default"}}
{"data":{"layout-restorer:data":{"main":{"dock":{"type":"tab-area","currentIndex":0,"widgets":["notebook:day1.ipynb"]},"current":"notebook:day1.ipynb"},"down":{"size":0,"widgets":[]},"left":{"collapsed":false,"current":"filebrowser","widgets":["filebrowser","running-sessions","@jupyterlab/toc:plugin","extensionmanager.main-view"]},"right":{"collapsed":true,"widgets":["jp-property-inspector","debugger-sidebar"]},"relativeSizes":[0.21566265060240963,0.7843373493975904,0]},"file-browser-filebrowser:cwd":{"path":""},"notebook:day1.ipynb":{"data":{"path":"day1.ipynb","factory":"Notebook"}}},"metadata":{"id":"default"}}
75 changes: 39 additions & 36 deletions notes/day1.ipynb

Large diffs are not rendered by default.

97 changes: 93 additions & 4 deletions solution/.ipynb_checkpoints/worksheet1_solution-checkpoint.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@
"name": "stderr",
"output_type": "stream",
"text": [
"── \u001b[1mAttaching core tidyverse packages\u001b[22m ──────────────────────── tidyverse 2.0.0 ──\n",
"── \u001b[1mAttaching core tidyverse packages\u001b[22m ──────────────────────────────────────────────────────────────── tidyverse 2.0.0 ──\n",
"\u001b[32m✔\u001b[39m \u001b[34mdplyr \u001b[39m 1.1.4 \u001b[32m✔\u001b[39m \u001b[34mreadr \u001b[39m 2.1.5\n",
"\u001b[32m✔\u001b[39m \u001b[34mforcats \u001b[39m 1.0.0 \u001b[32m✔\u001b[39m \u001b[34mstringr \u001b[39m 1.5.1\n",
"\u001b[32m✔\u001b[39m \u001b[34mggplot2 \u001b[39m 3.5.1 \u001b[32m✔\u001b[39m \u001b[34mtibble \u001b[39m 3.2.1\n",
"\u001b[32m✔\u001b[39m \u001b[34mlubridate\u001b[39m 1.9.3 \u001b[32m✔\u001b[39m \u001b[34mtidyr \u001b[39m 1.3.1\n",
"\u001b[32m✔\u001b[39m \u001b[34mpurrr \u001b[39m 1.0.2 \n",
"── \u001b[1mConflicts\u001b[22m ────────────────────────────────────────── tidyverse_conflicts() ──\n",
"── \u001b[1mConflicts\u001b[22m ────────────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──\n",
"\u001b[31m✖\u001b[39m \u001b[34mdplyr\u001b[39m::\u001b[32mfilter()\u001b[39m masks \u001b[34mstats\u001b[39m::filter()\n",
"\u001b[31m✖\u001b[39m \u001b[34mdplyr\u001b[39m::\u001b[32mlag()\u001b[39m masks \u001b[34mstats\u001b[39m::lag()\n",
"\u001b[36mℹ\u001b[39m Use the conflicted package (\u001b[3m\u001b[34m<http://conflicted.r-lib.org/>\u001b[39m\u001b[23m) to force all conflicts to become errors\n"
Expand All @@ -89,7 +89,7 @@
"output_type": "stream",
"text": [
"\u001b[1mRows: \u001b[22m\u001b[34m50\u001b[39m \u001b[1mColumns: \u001b[22m\u001b[34m12\u001b[39m\n",
"\u001b[36m──\u001b[39m \u001b[1mColumn specification\u001b[22m \u001b[36m────────────────────────────────────────────────────────\u001b[39m\n",
"\u001b[36m──\u001b[39m \u001b[1mColumn specification\u001b[22m \u001b[36m────────────────────────────────────────────────────────────────────────────────────────────────\u001b[39m\n",
"\u001b[1mDelimiter:\u001b[22m \",\"\n",
"\u001b[31mchr\u001b[39m (3): artist_name, track_name, genres\n",
"\u001b[32mdbl\u001b[39m (8): danceability, energy, loudness, key, tempo, duration_ms, time_sign...\n",
Expand All @@ -115,10 +115,99 @@
},
"outputs": [],
"source": [
"# Create 'pop' column \n",
"\n",
"spotify <- spotify |> \n",
" mutate(pop = if_else(str_detect(genres, \"pop\"), \"yes\", \"no\"))"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "c692ffdf-3c60-4850-8c19-015e6a8fefce",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"text/html": [
"<table class=\"dataframe\">\n",
"<caption>A tibble: 6 × 13</caption>\n",
"<thead>\n",
"\t<tr><th scope=col>artist_name</th><th scope=col>track_name</th><th scope=col>album_release_date</th><th scope=col>genres</th><th scope=col>danceability</th><th scope=col>energy</th><th scope=col>loudness</th><th scope=col>key</th><th scope=col>tempo</th><th scope=col>duration_ms</th><th scope=col>time_signature</th><th scope=col>popularity</th><th scope=col>pop</th></tr>\n",
"\t<tr><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;date&gt;</th><th scope=col>&lt;chr&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;dbl&gt;</th><th scope=col>&lt;chr&gt;</th></tr>\n",
"</thead>\n",
"<tbody>\n",
"\t<tr><td>Miley Cyrus </td><td>Flowers </td><td>2023-08-18</td><td>['pop'] </td><td>0.706</td><td>0.691</td><td>-4.775</td><td> 0</td><td>118.048</td><td>200600</td><td>4</td><td>94</td><td>yes</td></tr>\n",
"\t<tr><td><span style=white-space:pre-wrap>SZA </span></td><td><span style=white-space:pre-wrap>Kill Bill </span></td><td>2022-12-08</td><td><span style=white-space:pre-wrap>['pop', 'r&amp;b', 'rap'] </span></td><td>0.644</td><td>0.735</td><td>-5.747</td><td> 8</td><td> 88.980</td><td>153947</td><td>4</td><td>86</td><td>yes</td></tr>\n",
"\t<tr><td>Harry Styles </td><td>As It Was </td><td>2022-05-20</td><td>['pop'] </td><td>0.520</td><td>0.731</td><td>-5.338</td><td> 6</td><td>173.930</td><td>167303</td><td>4</td><td>95</td><td>yes</td></tr>\n",
"\t<tr><td>Jung Kook </td><td>Seven (feat. Latto) (Explicit Ver.)</td><td>2023-11-03</td><td>['k-pop'] </td><td>0.790</td><td>0.831</td><td>-4.185</td><td>11</td><td>124.987</td><td>183551</td><td>4</td><td>90</td><td>yes</td></tr>\n",
"\t<tr><td>Eslabon Armado</td><td>Ella Baila Sola </td><td>2023-04-28</td><td>['corrido', 'corridos tumbados', 'sad sierreno', 'sierreno']</td><td>0.668</td><td>0.758</td><td>-5.176</td><td> 5</td><td>147.989</td><td>165671</td><td>3</td><td>86</td><td>no </td></tr>\n",
"\t<tr><td>Taylor Swift </td><td>Cruel Summer </td><td>2019-08-23</td><td>['pop'] </td><td>0.552</td><td>0.702</td><td>-5.707</td><td> 9</td><td>169.994</td><td>178427</td><td>4</td><td>99</td><td>yes</td></tr>\n",
"</tbody>\n",
"</table>\n"
],
"text/latex": [
"A tibble: 6 × 13\n",
"\\begin{tabular}{lllllllllllll}\n",
" artist\\_name & track\\_name & album\\_release\\_date & genres & danceability & energy & loudness & key & tempo & duration\\_ms & time\\_signature & popularity & pop\\\\\n",
" <chr> & <chr> & <date> & <chr> & <dbl> & <dbl> & <dbl> & <dbl> & <dbl> & <dbl> & <dbl> & <dbl> & <chr>\\\\\n",
"\\hline\n",
"\t Miley Cyrus & Flowers & 2023-08-18 & {[}'pop'{]} & 0.706 & 0.691 & -4.775 & 0 & 118.048 & 200600 & 4 & 94 & yes\\\\\n",
"\t SZA & Kill Bill & 2022-12-08 & {[}'pop', 'r\\&b', 'rap'{]} & 0.644 & 0.735 & -5.747 & 8 & 88.980 & 153947 & 4 & 86 & yes\\\\\n",
"\t Harry Styles & As It Was & 2022-05-20 & {[}'pop'{]} & 0.520 & 0.731 & -5.338 & 6 & 173.930 & 167303 & 4 & 95 & yes\\\\\n",
"\t Jung Kook & Seven (feat. Latto) (Explicit Ver.) & 2023-11-03 & {[}'k-pop'{]} & 0.790 & 0.831 & -4.185 & 11 & 124.987 & 183551 & 4 & 90 & yes\\\\\n",
"\t Eslabon Armado & Ella Baila Sola & 2023-04-28 & {[}'corrido', 'corridos tumbados', 'sad sierreno', 'sierreno'{]} & 0.668 & 0.758 & -5.176 & 5 & 147.989 & 165671 & 3 & 86 & no \\\\\n",
"\t Taylor Swift & Cruel Summer & 2019-08-23 & {[}'pop'{]} & 0.552 & 0.702 & -5.707 & 9 & 169.994 & 178427 & 4 & 99 & yes\\\\\n",
"\\end{tabular}\n"
],
"text/markdown": [
"\n",
"A tibble: 6 × 13\n",
"\n",
"| artist_name &lt;chr&gt; | track_name &lt;chr&gt; | album_release_date &lt;date&gt; | genres &lt;chr&gt; | danceability &lt;dbl&gt; | energy &lt;dbl&gt; | loudness &lt;dbl&gt; | key &lt;dbl&gt; | tempo &lt;dbl&gt; | duration_ms &lt;dbl&gt; | time_signature &lt;dbl&gt; | popularity &lt;dbl&gt; | pop &lt;chr&gt; |\n",
"|---|---|---|---|---|---|---|---|---|---|---|---|---|\n",
"| Miley Cyrus | Flowers | 2023-08-18 | ['pop'] | 0.706 | 0.691 | -4.775 | 0 | 118.048 | 200600 | 4 | 94 | yes |\n",
"| SZA | Kill Bill | 2022-12-08 | ['pop', 'r&amp;b', 'rap'] | 0.644 | 0.735 | -5.747 | 8 | 88.980 | 153947 | 4 | 86 | yes |\n",
"| Harry Styles | As It Was | 2022-05-20 | ['pop'] | 0.520 | 0.731 | -5.338 | 6 | 173.930 | 167303 | 4 | 95 | yes |\n",
"| Jung Kook | Seven (feat. Latto) (Explicit Ver.) | 2023-11-03 | ['k-pop'] | 0.790 | 0.831 | -4.185 | 11 | 124.987 | 183551 | 4 | 90 | yes |\n",
"| Eslabon Armado | Ella Baila Sola | 2023-04-28 | ['corrido', 'corridos tumbados', 'sad sierreno', 'sierreno'] | 0.668 | 0.758 | -5.176 | 5 | 147.989 | 165671 | 3 | 86 | no |\n",
"| Taylor Swift | Cruel Summer | 2019-08-23 | ['pop'] | 0.552 | 0.702 | -5.707 | 9 | 169.994 | 178427 | 4 | 99 | yes |\n",
"\n"
],
"text/plain": [
" artist_name track_name album_release_date\n",
"1 Miley Cyrus Flowers 2023-08-18 \n",
"2 SZA Kill Bill 2022-12-08 \n",
"3 Harry Styles As It Was 2022-05-20 \n",
"4 Jung Kook Seven (feat. Latto) (Explicit Ver.) 2023-11-03 \n",
"5 Eslabon Armado Ella Baila Sola 2023-04-28 \n",
"6 Taylor Swift Cruel Summer 2019-08-23 \n",
" genres danceability\n",
"1 ['pop'] 0.706 \n",
"2 ['pop', 'r&b', 'rap'] 0.644 \n",
"3 ['pop'] 0.520 \n",
"4 ['k-pop'] 0.790 \n",
"5 ['corrido', 'corridos tumbados', 'sad sierreno', 'sierreno'] 0.668 \n",
"6 ['pop'] 0.552 \n",
" energy loudness key tempo duration_ms time_signature popularity pop\n",
"1 0.691 -4.775 0 118.048 200600 4 94 yes\n",
"2 0.735 -5.747 8 88.980 153947 4 86 yes\n",
"3 0.731 -5.338 6 173.930 167303 4 95 yes\n",
"4 0.831 -4.185 11 124.987 183551 4 90 yes\n",
"5 0.758 -5.176 5 147.989 165671 3 86 no \n",
"6 0.702 -5.707 9 169.994 178427 4 99 yes"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"head(spotify)"
]
},
{
"cell_type": "markdown",
"id": "f780e659-49c9-454c-abe6-bf85c84498ec",
Expand Down Expand Up @@ -1256,7 +1345,7 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 19,
"id": "01145801-dec5-4eaf-b394-9b7c7c3bf9fa",
"metadata": {
"tags": []
Expand Down
Loading

0 comments on commit 5ef4896

Please sign in to comment.