# Buggy code
def tsplot(series, plotf, **kwargs):
    """
    Plots a Series on the given Matplotlib axes or the current axes

    Parameters
    ----------
    axes : Axes
    series : Series

    Notes
    _____
    Supports same kwargs as Axes.plot

    """
    # Used inferred freq is possible, need a test case for inferred
    if "ax" in kwargs:
        ax = kwargs.pop("ax")
    else:
        import matplotlib.pyplot as plt

        ax = plt.gca()

    freq = _get_freq(ax, series)
    # resample against axes freq if necessary
    if freq is None:  # pragma: no cover
        raise ValueError("Cannot use dynamic axis without frequency info")
    else:
        ax_freq = getattr(ax, "freq", None)
        if (ax_freq is not None) and (freq != ax_freq):
            if frequencies.is_subperiod(freq, ax_freq):  # downsample
                how = kwargs.pop("how", "last")
                series = series.resample(ax_freq, how=how)
            elif frequencies.is_superperiod(freq, ax_freq):
                series = series.resample(ax_freq)
            else:  # one freq is weekly
                how = kwargs.pop("how", "last")
                series = series.resample("D", how=how, fill_method="pad")
                series = series.resample(ax_freq, how=how, fill_method="pad")
            freq = ax_freq

    # Convert DatetimeIndex to PeriodIndex
    if isinstance(series.index, DatetimeIndex):
        series = series.to_period(freq=freq)

    style = kwargs.pop("style", None)

    # Specialized ts plotting attributes for Axes
    ax.freq = freq
    xaxis = ax.get_xaxis()
    xaxis.freq = freq
    ax.legendlabels = [kwargs.get("label", None)]
    ax.view_interval = None
    ax.date_axis_info = None

    # format args and lot
    args = _maybe_mask(series)

    if style is not None:
        args.append(style)

    plotf(ax, *args, **kwargs)

    format_dateaxis(ax, ax.freq)

    left, right = _get_xlim(ax.get_lines())
    ax.set_xlim(left, right)

    return ax


# Traceback (IndexError)
In [1]: from pandas import *

In [2]: a = DataFrame(columns=['column1'], data=[1])

In [3]: b = DataFrame(columns=['column1'])

In [4]: a.merge(b, on=['column1'], how='left')


IndexError                                Traceback (most recent call last)
IndexError: index out of range for array

# Fixed code
def tsplot(series, plotf, **kwargs):
    """
    Plots a Series on the given Matplotlib axes or the current axes

    Parameters
    ----------
    axes : Axes
    series : Series

    Notes
    _____
    Supports same kwargs as Axes.plot

    """
    # Used inferred freq is possible, need a test case for inferred
    if "ax" in kwargs:
        ax = kwargs.pop("ax")
    else:
        import matplotlib.pyplot as plt

        ax = plt.gca()

    freq = _get_freq(ax, series)
    # resample against axes freq if necessary
    if freq is None:  # pragma: no cover
        raise ValueError("Cannot use dynamic axis without frequency info")
    else:
        # Convert DatetimeIndex to PeriodIndex
        if isinstance(series.index, DatetimeIndex):
            series = series.to_period(freq=freq)
        freq, ax_freq, series = _maybe_resample(series, ax, freq, plotf, kwargs)

    # Set ax with freq info
    _decorate_axes(ax, freq, kwargs)

    # mask missing values
    args = _maybe_mask(series)

    # how to make sure ax.clear() flows through?
    if not hasattr(ax, "_plot_data"):
        ax._plot_data = []
    ax._plot_data.append((series, kwargs))

    # styles
    style = kwargs.pop("style", None)
    if style is not None:
        args.append(style)

    lines = plotf(ax, *args, **kwargs)
    label = kwargs.get("label", None)

    # set date formatter, locators and rescale limits
    format_dateaxis(ax, ax.freq)
    left, right = _get_xlim(ax.get_lines())
    ax.set_xlim(left, right)

    return lines