我想为下面的数据集创建一个Chord图,其中前两列作为物理位置,第三列显示有多少人访问了这两个列。
Place1 Place2 Count
US UK 200
FR US 450
UK US 200
NL FR 150
IT FR 500我试着使用全息视图,但我不能让它工作
nodes = hv.Dataset(df, 'Place1', 'Place2')
chord = hv.Chord((df, nodes), ['Place1', 'Place2'], ['Count'])
graph = chord.select(selection_mode='nodes')但我得到以下错误: DataError:没有可用的存储后端能够支持提供的数据格式。
如何使用此数据帧创建Chord图?
发布于 2020-11-27 16:36:39
一个可能的解决方案如下所示。请记住,您的共享数据并不是很大,因此生成的chord图也很糟糕。
import holoviews as hv
chords = chord.groupby(by=["Place1", "Place2"]).sum()[["Count"]].reset_index()
chords = chords.sort_values(by="Count", ascending=False)
CChord = hv.Chord(chords)
print(CChord)
hv.extension("bokeh")
CChord最后一部分hv.extension("bokeh")是可视化所必需的。你甚至可以像这样添加标签:
cities = list(set(chords["Place1"].unique().tolist() + chords["Place2"].unique().tolist()))
cities_dataset = hv.Dataset(pd.DataFrame(cities, columns=["City"]))

https://stackoverflow.com/questions/65030626
复制相似问题