|
12 | 12 | }, |
13 | 13 | { |
14 | 14 | "cell_type": "code", |
15 | | - "execution_count": null, |
| 15 | + "execution_count": 2, |
16 | 16 | "id": "31cf5f11-c2d1-4fb5-bfa2-d16d25e6b130", |
17 | 17 | "metadata": {}, |
18 | | - "outputs": [], |
| 18 | + "outputs": [ |
| 19 | + { |
| 20 | + "name": "stdout", |
| 21 | + "output_type": "stream", |
| 22 | + "text": [ |
| 23 | + "Note: you may need to restart the kernel to use updated packages.\n" |
| 24 | + ] |
| 25 | + } |
| 26 | + ], |
19 | 27 | "source": [ |
20 | 28 | "%pip install --quiet pandas==2.3.2 wordcloud==1.9.4" |
21 | 29 | ] |
22 | 30 | }, |
23 | 31 | { |
24 | 32 | "cell_type": "code", |
25 | | - "execution_count": 12, |
| 33 | + "execution_count": 3, |
26 | 34 | "id": "564a2258", |
27 | 35 | "metadata": {}, |
28 | 36 | "outputs": [ |
29 | 37 | { |
30 | 38 | "name": "stdout", |
31 | 39 | "output_type": "stream", |
32 | 40 | "text": [ |
| 41 | + " ids names popularity followers \\\n", |
| 42 | + "0 2P3aLwJ41aRYkyFFw2FRM7 sam concepcion 45 168497 \n", |
| 43 | + "1 2FCVB3cfCC0e3O8G7Gs8t6 bleib modern 28 23349 \n", |
| 44 | + "2 3ZaPFQ05J5qSM5I3Smbp44 tevvez 58 259154 \n", |
| 45 | + "3 71WUmUmWWaqqGtVP8MlPJb semi.official 4 1050 \n", |
| 46 | + "4 0MVM5Khj39EkpVtLvU9Ujp ovsicori 4 316 \n", |
| 47 | + "\n", |
| 48 | + " genres first_release last_release \\\n", |
| 49 | + "0 opm 2007 2023 \n", |
| 50 | + "1 dark post-punk, modern goth 2014 2024 \n", |
| 51 | + "2 gym hardstyle 2018 2024 \n", |
| 52 | + "3 abstract hip hop, minnesota hip hop 2003 2003 \n", |
| 53 | + "4 ambient 2017 2023 \n", |
| 54 | + "\n", |
| 55 | + " num_releases num_tracks monthly_listeners \n", |
| 56 | + "0 20 1 583900.0 \n", |
| 57 | + "1 14 3 40842.0 \n", |
| 58 | + "2 20 1 1521671.0 \n", |
| 59 | + "3 1 17 820.0 \n", |
| 60 | + "4 8 5 1025.0 \n", |
33 | 61 | "92\n", |
34 | 62 | "[ 3 5 1 1 20 1 2 6 3 1 1 2 2 1 1 2 1 1 2 1 3 2 2 1\n", |
35 | 63 | " 1 13 1 8 23 1 1 4 2 3 1 1 1 1 1 1 1 1 9 2 4 9 1 3\n", |
|
44 | 72 | "import matplotlib.pyplot as plt\n", |
45 | 73 | "from wordcloud import WordCloud\n", |
46 | 74 | "\n", |
47 | | - "df_csv = pd.read_csv(\"artists.csv\")\n", |
| 75 | + "df_positive = pd.read_csv(\"artists_positive.csv\")\n", |
| 76 | + "df_negative = pd.read_csv(\"artists_negative.csv\")\n", |
48 | 77 | "df_json = pd.read_json(\"spotify-artists.json\")\n", |
49 | 78 | "df_json_normalized = pd.json_normalize(df_json[\"artists\"])\n", |
50 | 79 | "\n", |
|
62 | 91 | " \"Image\": image}\n", |
63 | 92 | "\n", |
64 | 93 | "df_json_final = pd.DataFrame(data)\n", |
65 | | - "df = df_json_final.merge(df_csv, on='SpotifyId', how='inner')\n", |
66 | | - "df[\"Date\"] = pd.to_datetime(df[\"Date\"], format='%Y%m%d')\n", |
67 | | - "#print(df.head())\n", |
| 94 | + "df = df_json_final.merge(df_positive, on=\"SpotifyId\", how=\"inner\")\n", |
| 95 | + "df[\"Date\"] = pd.to_datetime(df[\"Date\"], format=\"%Y%m%d\")\n", |
68 | 96 | "\n", |
69 | 97 | "flat_genres = df.explode(\"Genres\")\n", |
70 | | - "#print(flat_genres)\n", |
71 | 98 | "\n", |
72 | 99 | "unique, counts = np.unique(flat_genres[\"Genres\"], return_counts=True)\n", |
73 | 100 | "print(len(unique))\n", |
|
202 | 229 | ], |
203 | 230 | "metadata": { |
204 | 231 | "kernelspec": { |
205 | | - "display_name": "Week1", |
| 232 | + "display_name": "Python 3 (ipykernel)", |
206 | 233 | "language": "python", |
207 | | - "name": "week1" |
| 234 | + "name": "python3" |
208 | 235 | }, |
209 | 236 | "language_info": { |
210 | 237 | "codemirror_mode": { |
|
216 | 243 | "name": "python", |
217 | 244 | "nbconvert_exporter": "python", |
218 | 245 | "pygments_lexer": "ipython3", |
219 | | - "version": "3.12.3" |
| 246 | + "version": "3.10.12" |
220 | 247 | } |
221 | 248 | }, |
222 | 249 | "nbformat": 4, |
|
0 commit comments