From 202efd8a9cf7cd3b4d1d3b33666d2072ce509264 Mon Sep 17 00:00:00 2001 From: Tobi Date: Thu, 13 Apr 2023 00:44:03 -0700 Subject: [PATCH] moving codes to new file --- analysis/analysis3_temp.ipynb | 2 +- analysis/ungraded/Pesron 2.ipynb | 919 +++++++++++++++++++++++++++++++ 2 files changed, 920 insertions(+), 1 deletion(-) create mode 100644 analysis/ungraded/Pesron 2.ipynb diff --git a/analysis/analysis3_temp.ipynb b/analysis/analysis3_temp.ipynb index 1036574..047ec62 100644 --- a/analysis/analysis3_temp.ipynb +++ b/analysis/analysis3_temp.ipynb @@ -2050,7 +2050,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" } diff --git a/analysis/ungraded/Pesron 2.ipynb b/analysis/ungraded/Pesron 2.ipynb new file mode 100644 index 0000000..b253e43 --- /dev/null +++ b/analysis/ungraded/Pesron 2.ipynb @@ -0,0 +1,919 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "9e06afe0-8747-4db9-8b52-2d1f50110405", + "metadata": {}, + "source": [ + "### Cleaning the Data" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2fc00132-945a-4eb9-8ba4-5d8eefe275f6", + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np\n", + "import pandas as pd" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5831223c-6b47-4cdd-adb9-5f4c49145950", + "metadata": {}, + "outputs": [], + "source": [ + "music = pd.read_csv(\"../../data/raw/song_data.csv.zip\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1ce50db4-486b-4747-8c38-41d7f3b0bb7b", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
song_namesong_popularitysong_duration_msacousticnessdanceabilityenergyinstrumentalnesskeylivenessloudnessaudio_modespeechinesstempotime_signatureaudio_valence
0Boulevard of Broken Dreams732623330.0055200.4960.6820.00002980.0589-4.09510.0294167.06040.474
1In The End662169330.0103000.5420.8530.00000030.1080-6.40700.0498105.25640.370
2Seven Nation Army762317330.0081700.7370.4630.44700000.2550-7.82810.0792123.88140.324
3By The Way742169330.0264000.4510.9700.00355000.1020-4.93810.1070122.44440.198
4How You Remind Me562238260.0009540.4470.7660.000000100.1130-5.06510.0313172.01140.574
................................................
495China Grove671953060.3190000.6230.9100.00044890.0810-8.44810.0384145.62440.745
496Foreplay / Long Time644676400.0097500.4360.6570.00748050.0931-8.86810.0541118.69340.210
497Come Sail Away593650000.1600000.2870.5620.00000000.1030-7.54910.0304147.62240.126
498Give A Little Bit722481730.0694000.5310.8180.00960020.2630-5.35810.045290.76740.471
499Doctor My Eyes641999060.2660000.4800.6260.00005750.0857-8.40610.029475.63040.542
\n", + "

500 rows × 15 columns

\n", + "
" + ], + "text/plain": [ + " song_name song_popularity song_duration_ms \\\n", + "0 Boulevard of Broken Dreams 73 262333 \n", + "1 In The End 66 216933 \n", + "2 Seven Nation Army 76 231733 \n", + "3 By The Way 74 216933 \n", + "4 How You Remind Me 56 223826 \n", + ".. ... ... ... \n", + "495 China Grove 67 195306 \n", + "496 Foreplay / Long Time 64 467640 \n", + "497 Come Sail Away 59 365000 \n", + "498 Give A Little Bit 72 248173 \n", + "499 Doctor My Eyes 64 199906 \n", + "\n", + " acousticness danceability energy instrumentalness key liveness \\\n", + "0 0.005520 0.496 0.682 0.000029 8 0.0589 \n", + "1 0.010300 0.542 0.853 0.000000 3 0.1080 \n", + "2 0.008170 0.737 0.463 0.447000 0 0.2550 \n", + "3 0.026400 0.451 0.970 0.003550 0 0.1020 \n", + "4 0.000954 0.447 0.766 0.000000 10 0.1130 \n", + ".. ... ... ... ... ... ... \n", + "495 0.319000 0.623 0.910 0.000448 9 0.0810 \n", + "496 0.009750 0.436 0.657 0.007480 5 0.0931 \n", + "497 0.160000 0.287 0.562 0.000000 0 0.1030 \n", + "498 0.069400 0.531 0.818 0.009600 2 0.2630 \n", + "499 0.266000 0.480 0.626 0.000057 5 0.0857 \n", + "\n", + " loudness audio_mode speechiness tempo time_signature audio_valence \n", + "0 -4.095 1 0.0294 167.060 4 0.474 \n", + "1 -6.407 0 0.0498 105.256 4 0.370 \n", + "2 -7.828 1 0.0792 123.881 4 0.324 \n", + "3 -4.938 1 0.1070 122.444 4 0.198 \n", + "4 -5.065 1 0.0313 172.011 4 0.574 \n", + ".. ... ... ... ... ... ... \n", + "495 -8.448 1 0.0384 145.624 4 0.745 \n", + "496 -8.868 1 0.0541 118.693 4 0.210 \n", + "497 -7.549 1 0.0304 147.622 4 0.126 \n", + "498 -5.358 1 0.0452 90.767 4 0.471 \n", + "499 -8.406 1 0.0294 75.630 4 0.542 \n", + "\n", + "[500 rows x 15 columns]" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "songs = music.loc[0:499]\n", + "songs" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2fbf950b-8041-4311-92b4-f26acca87730", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
song_namesong_popularitysong_duration_msacousticnessdanceabilityenergyinstrumentalnesskeylivenessloudnessspeechinesstempoaudio_valence
0Boulevard of Broken Dreams732623330.0055200.4960.6820.00002980.0589-4.0950.0294167.0600.474
1In The End662169330.0103000.5420.8530.00000030.1080-6.4070.0498105.2560.370
2Seven Nation Army762317330.0081700.7370.4630.44700000.2550-7.8280.0792123.8810.324
3By The Way742169330.0264000.4510.9700.00355000.1020-4.9380.1070122.4440.198
4How You Remind Me562238260.0009540.4470.7660.000000100.1130-5.0650.0313172.0110.574
..........................................
495China Grove671953060.3190000.6230.9100.00044890.0810-8.4480.0384145.6240.745
496Foreplay / Long Time644676400.0097500.4360.6570.00748050.0931-8.8680.0541118.6930.210
497Come Sail Away593650000.1600000.2870.5620.00000000.1030-7.5490.0304147.6220.126
498Give A Little Bit722481730.0694000.5310.8180.00960020.2630-5.3580.045290.7670.471
499Doctor My Eyes641999060.2660000.4800.6260.00005750.0857-8.4060.029475.6300.542
\n", + "

500 rows × 13 columns

\n", + "
" + ], + "text/plain": [ + " song_name song_popularity song_duration_ms \\\n", + "0 Boulevard of Broken Dreams 73 262333 \n", + "1 In The End 66 216933 \n", + "2 Seven Nation Army 76 231733 \n", + "3 By The Way 74 216933 \n", + "4 How You Remind Me 56 223826 \n", + ".. ... ... ... \n", + "495 China Grove 67 195306 \n", + "496 Foreplay / Long Time 64 467640 \n", + "497 Come Sail Away 59 365000 \n", + "498 Give A Little Bit 72 248173 \n", + "499 Doctor My Eyes 64 199906 \n", + "\n", + " acousticness danceability energy instrumentalness key liveness \\\n", + "0 0.005520 0.496 0.682 0.000029 8 0.0589 \n", + "1 0.010300 0.542 0.853 0.000000 3 0.1080 \n", + "2 0.008170 0.737 0.463 0.447000 0 0.2550 \n", + "3 0.026400 0.451 0.970 0.003550 0 0.1020 \n", + "4 0.000954 0.447 0.766 0.000000 10 0.1130 \n", + ".. ... ... ... ... ... ... \n", + "495 0.319000 0.623 0.910 0.000448 9 0.0810 \n", + "496 0.009750 0.436 0.657 0.007480 5 0.0931 \n", + "497 0.160000 0.287 0.562 0.000000 0 0.1030 \n", + "498 0.069400 0.531 0.818 0.009600 2 0.2630 \n", + "499 0.266000 0.480 0.626 0.000057 5 0.0857 \n", + "\n", + " loudness speechiness tempo audio_valence \n", + "0 -4.095 0.0294 167.060 0.474 \n", + "1 -6.407 0.0498 105.256 0.370 \n", + "2 -7.828 0.0792 123.881 0.324 \n", + "3 -4.938 0.1070 122.444 0.198 \n", + "4 -5.065 0.0313 172.011 0.574 \n", + ".. ... ... ... ... \n", + "495 -8.448 0.0384 145.624 0.745 \n", + "496 -8.868 0.0541 118.693 0.210 \n", + "497 -7.549 0.0304 147.622 0.126 \n", + "498 -5.358 0.0452 90.767 0.471 \n", + "499 -8.406 0.0294 75.630 0.542 \n", + "\n", + "[500 rows x 13 columns]" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "songs_cleaned = songs.drop(['audio_mode', 'time_signature'], axis=1)\n", + "songs_cleaned\n", + "#Cleaning the data. Here I am cleaning the data by removing 2 columns that are not significant in my research or are just repetitive." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "8259a64a-4481-4068-bcf4-01bb9f0435c7", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
song_namesong_popularitysong_duration_msacousticnessdanceabilityenergyinstrumentalnesskeylivenessloudnessspeechinesstempoaudio_valencedanceable_valence
0Boulevard of Broken Dreams732623330.0055200.4960.6820.00002980.0589-4.0950.0294167.0600.4740.970
1In The End662169330.0103000.5420.8530.00000030.1080-6.4070.0498105.2560.3700.912
2Seven Nation Army762317330.0081700.7370.4630.44700000.2550-7.8280.0792123.8810.3241.061
3By The Way742169330.0264000.4510.9700.00355000.1020-4.9380.1070122.4440.1980.649
4How You Remind Me562238260.0009540.4470.7660.000000100.1130-5.0650.0313172.0110.5741.021
.............................................
495China Grove671953060.3190000.6230.9100.00044890.0810-8.4480.0384145.6240.7451.368
496Foreplay / Long Time644676400.0097500.4360.6570.00748050.0931-8.8680.0541118.6930.2100.646
497Come Sail Away593650000.1600000.2870.5620.00000000.1030-7.5490.0304147.6220.1260.413
498Give A Little Bit722481730.0694000.5310.8180.00960020.2630-5.3580.045290.7670.4711.002
499Doctor My Eyes641999060.2660000.4800.6260.00005750.0857-8.4060.029475.6300.5421.022
\n", + "

500 rows × 14 columns

\n", + "
" + ], + "text/plain": [ + " song_name song_popularity song_duration_ms \\\n", + "0 Boulevard of Broken Dreams 73 262333 \n", + "1 In The End 66 216933 \n", + "2 Seven Nation Army 76 231733 \n", + "3 By The Way 74 216933 \n", + "4 How You Remind Me 56 223826 \n", + ".. ... ... ... \n", + "495 China Grove 67 195306 \n", + "496 Foreplay / Long Time 64 467640 \n", + "497 Come Sail Away 59 365000 \n", + "498 Give A Little Bit 72 248173 \n", + "499 Doctor My Eyes 64 199906 \n", + "\n", + " acousticness danceability energy instrumentalness key liveness \\\n", + "0 0.005520 0.496 0.682 0.000029 8 0.0589 \n", + "1 0.010300 0.542 0.853 0.000000 3 0.1080 \n", + "2 0.008170 0.737 0.463 0.447000 0 0.2550 \n", + "3 0.026400 0.451 0.970 0.003550 0 0.1020 \n", + "4 0.000954 0.447 0.766 0.000000 10 0.1130 \n", + ".. ... ... ... ... ... ... \n", + "495 0.319000 0.623 0.910 0.000448 9 0.0810 \n", + "496 0.009750 0.436 0.657 0.007480 5 0.0931 \n", + "497 0.160000 0.287 0.562 0.000000 0 0.1030 \n", + "498 0.069400 0.531 0.818 0.009600 2 0.2630 \n", + "499 0.266000 0.480 0.626 0.000057 5 0.0857 \n", + "\n", + " loudness speechiness tempo audio_valence danceable_valence \n", + "0 -4.095 0.0294 167.060 0.474 0.970 \n", + "1 -6.407 0.0498 105.256 0.370 0.912 \n", + "2 -7.828 0.0792 123.881 0.324 1.061 \n", + "3 -4.938 0.1070 122.444 0.198 0.649 \n", + "4 -5.065 0.0313 172.011 0.574 1.021 \n", + ".. ... ... ... ... ... \n", + "495 -8.448 0.0384 145.624 0.745 1.368 \n", + "496 -8.868 0.0541 118.693 0.210 0.646 \n", + "497 -7.549 0.0304 147.622 0.126 0.413 \n", + "498 -5.358 0.0452 90.767 0.471 1.002 \n", + "499 -8.406 0.0294 75.630 0.542 1.022 \n", + "\n", + "[500 rows x 14 columns]" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "songs_cleaned['danceable_valence'] = songs_cleaned['danceability'] + songs_cleaned['audio_valence']\n", + "# These 2 variables have very similar values so I combined them\n", + "songs_cleaned" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "039610a3-a0c0-4382-a8b2-ba3d5646626f", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}