examples icon indicating copy to clipboard operation
examples copied to clipboard

IEX_stocks notebook TypeError

Open ablythed opened this issue 3 years ago • 0 comments

In #167, I updated the IEX project and all notebooks except IEX_stocks are working. The issue I ran into was that in the original notebook, the code

def xrange_filter(spikes, x_range):
    low, high = (None, None) if x_range is None else x_range
    ranged = spikes[low:high]
    return (ranged if len(ranged) < 600 else ranged.iloc[:0]).opts(spike_length=1, alpha=0)

causes an error later on:

  WARNING:param.dynamic_operation: Callable raised "TypeError("The DTypes <class 'numpy.dtype[float64]'> and <class 'numpy.dtype[datetime64]'> do not have a common DType. For example they cannot be stored in a single array unless the dtype is `object`.")".

Since xrange_filter shows up in both IEX_trading and IEX_stocks, I tried to change it both places to

def xrange_filter(spikes, x_range):
    low, high = (None, None) if x_range is None else x_range
    ranged = spikes[pd.to_datetime(low):pd.to_datetime(high)]
    return (ranged if len(ranged) < 600 else ranged.iloc[:0]).opts(spike_length=1, alpha=0)

This resolved the issue in IEX_trading, but not in IEX_stocks: the last cell in that notebook still gives that error, and I'm not sure what else to do to fix it. I'm pretty sure the issue lies in the function overlay_symbols, but I don't know where to go from there.

ablythed avatar Aug 16 '21 17:08 ablythed