找不到聚合列类别 - 当我使用 Hvplot 设置 datashader = True 时
Aggregation column category not found - when I set datashader = True with Hvplot
我正在使用 Hvplot 根据数据所属的类别创建 2 个散点图。
由于数据点太多,我用的是datashade。
当我不使用数据阴影时,我的情节工作正常。
但是,当我在下面的代码中设置 datashade=True 时,出现以下错误:
WARNING:param.dynamic_operation: Callable raised
"ValueError('Aggregation column category not found on :Scatter
[col1] (col2) element. Ensure the aggregator references an existing
dimension.',)". Invoked as dynamic_operation(height=300, scale=1.0,
width=1200, x_range=None, y_range=None)
ValueError: Aggregation column category not found on :Scatter [col1]
(col2) element. Ensure the aggregator references an existing
dimension.
示例代码:
# import libraries
import numpy as np
import pandas as pd
import hvplot
import hvplot.pandas
import holoviews as hv
hv.extension('bokeh')
from holoviews.operation.datashader import datashade
# create some sample data
sample_scatter1 = np.random.normal(loc=0.0, size=50)
sample_scatter2 = np.random.normal(loc=300., size=50)
sample_category = np.random.choice(2, size=50)
demo_df = pd.DataFrame({
'col1': sample_scatter1,
'col2': sample_scatter2,
'category': sample_category,
})
# this works fine if I would set datashade=False, but with datashade=True it gives an error
demo_df.hvplot(
kind='scatter',
x='col1', y='col2',
by='category',
subplots=True,
width=1200,
datashade=True
).cols(1)
我认为它试图在 'category' 列上进行聚合,尽管维度已按其分组。我已经在 hvPlot 中打开 this issue,希望尽快解决。现在您可以使用此解决方法:
demo_df.hvplot(
kind='scatter',
x='col1', y='col2',
groupby='category',
width=1200,
datashade=True
).layout().cols(1)
我正在使用 Hvplot 根据数据所属的类别创建 2 个散点图。
由于数据点太多,我用的是datashade。
当我不使用数据阴影时,我的情节工作正常。
但是,当我在下面的代码中设置 datashade=True 时,出现以下错误:
WARNING:param.dynamic_operation: Callable raised "ValueError('Aggregation column category not found on :Scatter
[col1] (col2) element. Ensure the aggregator references an existing dimension.',)". Invoked as dynamic_operation(height=300, scale=1.0, width=1200, x_range=None, y_range=None)ValueError: Aggregation column category not found on :Scatter [col1] (col2) element. Ensure the aggregator references an existing dimension.
示例代码:
# import libraries
import numpy as np
import pandas as pd
import hvplot
import hvplot.pandas
import holoviews as hv
hv.extension('bokeh')
from holoviews.operation.datashader import datashade
# create some sample data
sample_scatter1 = np.random.normal(loc=0.0, size=50)
sample_scatter2 = np.random.normal(loc=300., size=50)
sample_category = np.random.choice(2, size=50)
demo_df = pd.DataFrame({
'col1': sample_scatter1,
'col2': sample_scatter2,
'category': sample_category,
})
# this works fine if I would set datashade=False, but with datashade=True it gives an error
demo_df.hvplot(
kind='scatter',
x='col1', y='col2',
by='category',
subplots=True,
width=1200,
datashade=True
).cols(1)
我认为它试图在 'category' 列上进行聚合,尽管维度已按其分组。我已经在 hvPlot 中打开 this issue,希望尽快解决。现在您可以使用此解决方法:
demo_df.hvplot(
kind='scatter',
x='col1', y='col2',
groupby='category',
width=1200,
datashade=True
).layout().cols(1)