Python Holoview Object error
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

I am tying to follow a simple example with different data.

Example code:

http://holoviews.org/reference/elements/bokeh/Chord.html

My modification replaces the data use for the graph:

https://pastebin.com/dBYbcN96

But results in the following error:

ERROR:bokeh.core.validation.check:E-1001 (BAD_COLUMN_NAME): Glyph refers to nonexistent column name. This could either be due to a misspelling or typo, or due to an expected column being missing. : LegendItem(id='1245', ...)

You seem to be referencing to a links object on line 17 and 19, but you don't seem to be initializing the object with links = pd.DataFrame(data['links']) first.
Wuddrum 7 months ago
awarded to Wuddrum
Tags
python3

Crowdsource coding tasks.

1 Solution

Winning solution

This works for me:

import pandas as pd
import holoviews as hv
from holoviews import opts, dim
from bokeh.sampledata.les_mis import data

# trying to use different data here
data={'nodes':[{'name': 'Fred',         'group': 1},
               {'name': 'Barney',         'group': 1},
               {'name': 'Wilma',      'group': 1},
               {'name': 'Betty',     'group': 1}
               ],
    'links': [{'source': 1, 'target': 0, 'value': 1},
              {'source': 2, 'target': 0, 'value': 1},
              {'source': 2, 'target': 1, 'value': 1},
              {'source': 3, 'target': 2, 'value': 5}
              ] }

hv.extension('bokeh')
hv.output(size=200)

links = pd.DataFrame(data['links'])
hv.Chord(links)

nodes = hv.Dataset(pd.DataFrame(data['nodes']), 'index')
nodes.data.head()

chord = hv.Chord((links, nodes)).select(value=(4, None))
ob = chord.opts(
    opts.Chord(cmap='Category20', edge_cmap='Category20', edge_color=dim('source').str(), 
               labels='name', node_color=dim('index').str()))

hv.save(ob, 'out2.html')

Apart from not setting the links object, the problem was in your last link, it was 'source': 3, 'target': 3. A link can not reference itself.

Perfect, thank you!
broadreach 7 months ago