2

我试图在这里遵循示例:https ://anaconda.org/jbednar/nyc_taxi/notebook

但是,我无法让以下块工作,因为 MemoryError 总是在特定行抛出(注释掉):

def merged_images(x_range, y_range, w=plot_width, h=plot_height, how='log'):
    cvs = ds.Canvas(plot_width=w, plot_height=h, x_range=x_range, y_range=y_range)
    picks = cvs.points(df, 'pickup_x',  'pickup_y',  ds.count('passenger_count'))
    drops = cvs.points(df, 'dropoff_x', 'dropoff_y', ds.count('passenger_count'))
    #more_drops = tf.shade(drops.where(drops > picks), cmap=["darkblue", 'cornflowerblue'], how=how)
    #more_picks = tf.shade(picks.where(picks > drops), cmap=["darkred", 'orangered'],  how=how)
    img = tf.stack(more_picks,more_drops)
    return tf.dynspread(img, threshold=0.3, max_px=4)

p = base_plot(background_fill_color=background)
export(merged_images(*NYC),"NYCT_pickups_vs_dropoffs")
InteractiveImage(p, merged_images)

这里需要大量 RAM (>64GB),还是我错过了一些与内存相关的配置?我已经尝试使用当前版本的 Python 3.6 和相应的库(散景、datashader、jupyter)在 Windows 10 和 Linux 16.04(均为 64 位版本)上无济于事。

更新:我还注意到,即使我的df.tail()似乎符合(11842093 条记录),直方图结果(从histogram(agg.values)开始)与原始笔记本有很大不同(截至https://anaconda.org/jbednar/nyc_taxi/notebook?version =2016.08.18.1303)。

4

1 回答 1

1

根据@JamesA.Bednar 的评论:以及相关的提交:https : //github.com/bokeh/datashader/commit/9fbace5c7b00410bdac7b7662ee24e466bc66330,xarray>=0.8 出现问题

修复是“在比较/合并/连接之前重命名列以匹配”

结果:

def merged_images(x_range, y_range, w=plot_width, h=plot_height, how='log'):
    cvs = ds.Canvas(plot_width=w, plot_height=h, x_range=x_range, y_range=y_range)
    picks = cvs.points(df, 'pickup_x',  'pickup_y',  ds.count('passenger_count'))
    drops = cvs.points(df, 'dropoff_x', 'dropoff_y', ds.count('passenger_count'))
    drops = drops.rename({'dropoff_x': 'x', 'dropoff_y': 'y'}) # added line
    picks = picks.rename({'pickup_x': 'x', 'pickup_y': 'y'}) # added line
    more_drops = tf.shade(drops.where(drops > picks), cmap=["darkblue", 'cornflowerblue'], how=how)
    more_picks = tf.shade(picks.where(picks > drops), cmap=["darkred", 'orangered'],  how=how)
    img = tf.stack(more_picks,more_drops)
    return tf.dynspread(img, threshold=0.3, max_px=4)
于 2018-04-16T08:43:36.913 回答