Reputation: 39
I am working on a data https://www.kaggle.com/rodolfofigueroa/spotify-12m-songs
I wanted to analyze How was the mood of the songs released initially compared with those released in 2020? So I went for plotting year on the x-axis and valence on the y-axis. NOTE- Valence is the Measurement of how positive a track sounds, from 1 (extremely positive) to 0 (extremely negative).
I created this data frame to check the first 20 values and when I am plotting it on the x-axis I am getting row numbers. sorted_df_year['valence'][:20].plot(kind='bar',figsize=(20,5))
My question is how can I change the x-axis label to years (column present in the dataset)?
Upvotes: 1
Views: 65
Reputation: 35205
Since the expected output is not explicitly stated, I used a bar graph of averages grouped with the x-axis as year. Does it conform to your intended output?
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv('./data/tracks_features.csv', sep=',')
df.groupby('year')['valence'].mean().plot(kind='bar', figsize=(20,5))
Upvotes: 0