I've been going around in circles on this for a while and thought I'd post. I have a dataframe that has UserID, TimeSlot, and Count.
I'm trying to plot 2 UserIDs (3 & 4) on separate line charts, with TimeSlot along the x-axis, and a sum of count on the Y. I've tried referring to this excellent post but can't seem to get it right for my needs.
How can I fix this code?
userList = [3,4]
df.set_index('TimeSlot', inplace=True)
df2 = df.groupby('UserID')
ncols=2
nrows = int(np.ceil(df2.ngroups/ncols))
fig, axes = plt.subplots(nrows=4, ncols=ncols, figsize=(12,4), sharey=True)
for (key, ax) in zip(df2.groups.keys(), axes.flatten()):
df2.get_group(key).plot(ax=ax)
ax.legend()
plt.show()