code: def plot_events_distribution(events, num_bars=50, ax=None):
      
  
      if ax is None:
          f, ax = plt.subplots(1, 1, figsize=(18, 6))
  
      start = events.index.get_level_values('date').min()
      end = events.index.get_level_values('date').max()
      group_interval = (end - start) / num_bars
      grouper = pd.Grouper(level='date', freq=group_interval)
      events.groupby(grouper).count().plot(kind="bar", grid=False, ax=ax)
      ax.set(ylabel='Number of events',
             title='Distribution of events in time',
             xlabel='Date')
  
      return ax
docs: Plots the distribution of events in time.
  
      Parameters
      ----------
      events : pd.Series
          A pd.Series whose index contains at least 'date' level.
      num_bars : integer, optional
          Number of bars to plot
      ax : matplotlib.Axes, optional
          Axes upon which to plot.
  
      Returns
      -------
      ax : matplotlib.Axes