text_html_output_1.png
import pandas as pd

music_dataset = pd.read_csv('/kaggle/input/kaggledataupdated/KaggleData_updated.csv')

music_dataset.shape

music_update = music_dataset.set_index('id')

music_update['artists'] = music_update['artists'].str.strip("[]'")

music_update.isna().sum()

music_update.duplicated().sum()

music_update = music_update.drop_duplicates()

music_update.duplicated().value_counts()

nameColumn = music_update.pop('name')
artistColumn = music_update.pop('artists')

music_update.insert(0, 'name', nameColumn)
music_update.insert(1, 'artist', artistColumn)

music_update.drop('release_date', axis=1)

music_updated = music_update

Trends = music_updated[['acousticness', 'danceability', 'energy', 'instrumentalness', 'liveness', 'valence', 'year']]
sound_features = ['acousticness', 'danceability', 'energy', 'instrumentalness', 'liveness', 'valence']

def get_decade(year):
    period = int(year / 10) * 10
    decade = '{}s'.format(period)
    return decade
Trends['decade'] = Trends['year'].apply(get_decade)
Trends_updated = Trends.groupby('decade')[sound_features].mean()
Trends_updated

Trend_ms = music_updated[['year', 'duration_ms']]
Trend_ms['decade'] = Trend_ms['year'].apply(get_decade)
Trend_ms = Trend_ms.groupby('decade')['duration_ms'].mean()
Trend_ms.plot(legend=True, figsize=(15, 7))