<jupyter_start><jupyter_text>Setup 💻 (do not forget to run these cells before starting 👇)  1. Importing Libraries<jupyter_code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns<jupyter_output><empty_output><jupyter_text>2. Loading Spotify dataset<jupyter_code>df = pd.read_csv('https://storage.googleapis.com/introduction-to-data-science/spotify-dataset.csv')<jupyter_output><empty_output><jupyter_text>----------  Your Assignement starts here 🔥  1. Can you display the first 10 row of the dataset?<jupyter_code>df.head(10)<jupyter_output><empty_output><jupyter_text>2. Are there any missing values in the dataset?<jupyter_code>df.isnull().sum()<jupyter_output><empty_output><jupyter_text>3. How many songs are there in the dataset?<jupyter_code>df['name'].value_counts()<jupyter_output><empty_output><jupyter_text>4. How many artists?<jupyter_code>df['artists'].value_counts()<jupyter_output><empty_output><jupyter_text>5. What's the average duration of a song, in minutes?<jupyter_code>df['duration_ms'].mean()<jupyter_output><empty_output><jupyter_text>6. Can you plot the distribution of the durations?<jupyter_code>plt.figure(figsize= (15,8))
sns.violinplot(data= df, y='duration_ms')<jupyter_output><empty_output><jupyter_text>7. [Follow-up] Can you make this plot more readable by removing outliers (extreme values)?<jupyter_code>rd_df= df[df['duration_ms'] < 1000600] 
plt.figure(figsize= (15,8))
sns.violinplot(data= rd_df, y='duration_ms')<jupyter_output><empty_output><jupyter_text>We only remove 470 songs (out of almost 170k) and get a way more interesting plot!  8. What are the top 10 longest songs (duration)?<jupyter_code>df.sort_values(by= 'duration_ms', ascending=False,inplace=True)

df[['duration_ms','name']].head(10)<jupyter_output><empty_output><jupyter_text>9. How long would it take to listen to all the songs?<jupyter_code>days = int((39317989065 / (1000*60*60*24)))
days<jupyter_output><empty_output><jupyter_text>This length is expressed in milliseconds, let's convert to days!  10. What are the top 10 most popular songs? We would like a DataFrame with only the columns `artists`, `name` and `popularity` as output!<jupyter_code>df.sort_values(by= 'popularity', ascending=False,inplace=True)
df[['artists','name','popularity']].head(10)<jupyter_output><empty_output><jupyter_text>11. What is the most popular song before 2000?<jupyter_code>df.nlargest(10, 'popularity')
df[['popularity','name','year']]
df[df['year'] < 2000].head(10) ['name']<jupyter_output><empty_output><jupyter_text>12. Can you plot the distribution of `popularity`?<jupyter_code>plt.figure(figsize= (15,8))
sns.distplot(df['popularity'])<jupyter_output><empty_output><jupyter_text>13. What are the top 10 artists in terms of number of songs?<jupyter_code>df['artists'].value_counts().head(10)<jupyter_output><empty_output><jupyter_text>14. [Follow-up] can you make a bar chart out of this result?<jupyter_code>df['artists'].value_counts().head(10).plot(kind = 'bar')# Your code goes here 💪<jupyter_output><empty_output><jupyter_text>15. How many songs by key?<jupyter_code>df['key'].value_counts()<jupyter_output><empty_output><jupyter_text>16. [Follow-up] Can you plot a bar chart using Seaborn? Make sure the keys are sorted in a descending order.<jupyter_code>import seaborn as sns
sns.countplot(data=df, x='key')<jupyter_output><empty_output><jupyter_text>17. Can you plot a line graph representing the annual number of songs since 1921?<jupyter_code>import matplotlib.pyplot as plt
import numpy as np

songs = df['year'].value_counts().sort_index()

songs

plt.plot(songs)<jupyter_output><empty_output><jupyter_text>Last question! 👇  18. Can you visually check if there is relationship between `year` and `popularity`?<jupyter_code>#plt.figure(figsize= (15,8))
#sns.violinplot(data=df, x= 'year', y= 'popularity')

plt.figure(figsize= (15,8))
plt.scatter(df['year'], df['popularity'])
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13714141922496226, 'fraction_numerical': 0.028183190739808756, 'mean_word_length': 8.486873508353222, 'pattern_counts': {'":': 0, '<': 83, '<?xml version=': 0, '>': 81, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '20', 'dir': 'jupyter-structured-clean-dedup', 'id': '392313', 'license': 'MIT', 'n_tokens_mistral': 1547, 'n_tokens_neox': 1439, 'n_words': 318, 'path': 'Spotify-project.ipynb', 'repo_name': 'nakaokacynthia/SpotifyProject', 'size': '3974'}