I have the following dataframe df:
time_diff avg_trips_per_day
631 1.0
231 1.0
431 1.0
7031 1.0
17231 1.0
20000 20.0
21000 15.0
22000 10.0
I want to create a histogram with time_diff in X axis and avg_trips_per_day in Y axis in order to see the distribution of values of time_diff. So, Y axis is not the frequency of repetitions of X values in df, but it should be avg_trips_per_day.
The problem is that I don't know how to put time_diff into bins in order to handle it as a continuous variable.
This is what I try, but it puts all possible values of time_diff in X axis.
norm = plt.Normalize(df["avg_trips_per_day"].values.min(), df["avg_trips_per_day"].values.max())
colors = plt.cm.spring(norm(df["avg_trips_per_day"]))
plt.figure(figsize=(12,8))
ax = sns.barplot(x="time_diff", y="avg_trips_per_day", data=df, palette=colors)
plt.xticks(rotation='vertical', fontsize=12)
ax.grid(b=True, which='major', color='#d3d3d3', linewidth=1.0)
ax.grid(b=True, which='minor', color='#d3d3d3', linewidth=0.5)
plt.show()