# Buggy code
def HeatMap(
    data,
    x=None,
    y=None,
    values=None,
    stat="count",
    xscale="categorical",
    yscale="categorical",
    xgrid=False,
    ygrid=False,
    **kw,
):
    """Create a HeatMap chart using :class:`HeatMapBuilder <bokeh.charts.builder.heatmap_builder.HeatMapBuilder>`
    to render the geometry from values.

    A HeatMap is a 3 Dimensional chart that crosses two dimensions, then aggregates
    values if there are multiple that correspond to the intersection of the horizontal
    and vertical dimensions. The value that falls at the intersection is then mapped to a
    color in a palette. All values that map to the positions on the chart are binned into
    the same amount of bins as there are colors in the pallete.

    Args:
        values (iterable): iterable 2d representing the data series
            values matrix.

    In addition the the parameters specific to this chart,
    :ref:`userguide_charts_generic_arguments` are also accepted as keyword parameters.

    Returns:
        a new :class:`Chart <bokeh.charts.Chart>`

    Examples:

    .. bokeh-plot::
        :source-position: above

        from collections import OrderedDict
        from bokeh.charts import HeatMap, output_file, show

        # (dict, OrderedDict, lists, arrays and DataFrames are valid inputs)
        xyvalues = OrderedDict()
        xyvalues['apples'] = [4,5,8]
        xyvalues['bananas'] = [1,2,4]
        xyvalues['pears'] = [6,5,4]

        hm = HeatMap(xyvalues, title='Fruits')

        output_file('heatmap.html')
        show(hm)

    """
    kw["x"] = x
    kw["y"] = y
    kw["color"] = values
    chart = create_and_build(
        HeatMapBuilder,
        data,
        xscale=xscale,
        yscale=yscale,
        xgrid=xgrid,
        ygrid=ygrid,
        **kw,
    )
    chart.add_tools(HoverTool(tooltips=[("value", "@rate")]))
    return chart


# Traceback (OverflowError)
Traceback (most recent call last):
File "test.py", line 22, in <module>
hist = Histogram(df, values='values',  legend=True,
File "/Users/<username>/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/bokeh/charts/builder/histogram_builder.py", line 53, in Histogram
return create_and_build(HistogramBuilder, data, **kw)
File "/Users/<username>/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/bokeh/charts/_builder.py", line 64, in create_and_build
chart.add_builder(builder)
File "/Users/<username>/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/bokeh/charts/_chart.py", line 134, in add_builder
builder.create(self)
File "/Users/<username>/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/bokeh/charts/_builder.py", line 303, in create
chart.add_renderers(self, renderers)
File "/Users/<username>/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/bokeh/charts/_chart.py", line 129, in add_renderers
self.renderers += renderers
File "/Users/<username>/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/bokeh/charts/builder/bar_builder.py", line 228, in _yield_renderers
**group_kwargs)
File "/Users/<username>/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/bokeh/charts/glyphs.py", line 469, in __init__
super(HistogramGlyph, self).__init__(**kwargs)
File "/Users/<username>/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/bokeh/charts/_models.py", line 61, in __init__
self.setup()
File "/Users/<username>/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/bokeh/charts/_models.py", line 64, in setup
self.renderers = [renderer for renderer in self.build_renderers()]
File "/Users/<username>/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/bokeh/charts/glyphs.py", line 478, in build_renderers
self.bins = Bins(values=self.values, bin_count=self.bin_count)
File "/Users/<username>/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/bokeh/charts/stats.py", line 164, in __init__
super(Bins, self).__init__(**properties)
File "/Users/<username>/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/bokeh/charts/stats.py", line 23, in __init__
self._refresh()
File "/Users/<username>/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/bokeh/charts/stats.py", line 29, in _refresh
self.calculate()
File "/Users/<username>/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/bokeh/charts/stats.py", line 174, in calculate
binned, bin_edges = pd.cut(self.get_data(), self.bin_count, retbins=True, precision=0)
File "/Users/<username>/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pandas/tools/tile.py", line 100, in cut
bins = np.linspace(mn, mx, bins + 1, endpoint=True)
File "/Users/<username>/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/core/function_base.py", line 84, in linspace
num = int(num)
OverflowError: cannot convert float infinity to integer

# Fixed code
def HeatMap(
    data,
    x=None,
    y=None,
    values=None,
    stat="count",
    xscale="categorical",
    yscale="categorical",
    xgrid=False,
    ygrid=False,
    **kw,
):
    """Create a HeatMap chart using :class:`HeatMapBuilder <bokeh.charts.builder.heatmap_builder.HeatMapBuilder>`
    to render the geometry from values.

    A HeatMap is a 3 Dimensional chart that crosses two dimensions, then aggregates
    values if there are multiple that correspond to the intersection of the horizontal
    and vertical dimensions. The value that falls at the intersection is then mapped to a
    color in a palette. All values that map to the positions on the chart are binned into
    the same amount of bins as there are colors in the pallete.

    Args:
        values (iterable): iterable 2d representing the data series
            values matrix.

    In addition the the parameters specific to this chart,
    :ref:`userguide_charts_generic_arguments` are also accepted as keyword parameters.

    Returns:
        a new :class:`Chart <bokeh.charts.Chart>`

    Examples:

    .. bokeh-plot::
        :source-position: above

        from collections import OrderedDict
        from bokeh.charts import HeatMap, output_file, show

        # (dict, OrderedDict, lists, arrays and DataFrames are valid inputs)
        xyvalues = OrderedDict()
        xyvalues['apples'] = [4,5,8]
        xyvalues['bananas'] = [1,2,4]
        xyvalues['pears'] = [6,5,4]

        hm = HeatMap(xyvalues, title='Fruits')

        output_file('heatmap.html')
        show(hm)

    """
    kw["x"] = x
    kw["y"] = y
    kw["values"] = values
    chart = create_and_build(
        HeatMapBuilder,
        data,
        xscale=xscale,
        yscale=yscale,
        xgrid=xgrid,
        ygrid=ygrid,
        **kw,
    )
    chart.add_tools(HoverTool(tooltips=[(stat, "@values")]))
    return chart