Tell us what’s happening:
In my local jupyter notebook I am able to use an index as a column in the “sns.catplot()” function but I am not able to do so in gitpod despite identical code.
Note, This explanation of the issue will be be difficult to parse due to an inability to post multiple images. When I have the permission to do either, I will include the relevant images.
I was able to reformat the cleaned version of the dataframe to have seperate year and month columns and then I was able to regroup it in order to prepare for the bar chart using the code below:
time_group=cleaned_df.groupby(["year","month"])[["value"]].mean()
month_labels ={1:"January", 2:"February",3:"March",4:"April",5:"May",6:"June",7:"July",8:"August",9:"September",10:"October",11:"November",12:"December"}
time_group=time_group.replace({"month":month_labels})
time_group.index = time_group.index.set_levels([time_group.index.levels[0], pd.to_datetime(time_group.index.levels[1], format='%m').strftime('%B')], level=[0, 1])
In my local jupyter notebook the below code resulted in a barchart grouped by years and months:
g = sns.catplot(
data=time_group, kind="bar",
x="year", y="value", hue="month",
errorbar="sd", palette="dark", alpha=.6, height=6
)
g.despine(left=True)
g.set_axis_labels("Years", "Average Page Views")
g.legend.set_title("Months")
However, it did not work in the below gitpod
https://gitpod.io#snapshot/d463851f-7a6d-4d45-bdf2-c185069e64fa
Could you please explain the discrepancy?
I’d prefer not to change the basic approach since I already have been able to demonstrate that it works on my local development enviroment so I don’t think there’s any issue with using the index as a column in this function.
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 OPR/116.0.0.0
Challenge Information:
Data Analysis with Python Projects - Page View Time Series Visualizer