我正在尝试可视化此表单的数据:
timestamp senderId
0 735217 106758968942084595234
1 735217 114647222927547413607
2 735217 106758968942084595234
3 735217 106758968942084595234
4 735217 114647222927547413607
5 etc...
如果我不将geom_density
分开,则 senderId
有效:
df = pd.read_pickle('data.pkl')
df.columns = ['timestamp', 'senderId']
plot = ggplot(aes(x='timestamp'), data=df) + geom_density()
print plot
结果看起来像预期的那样:
但是,如果我想单独显示senderId
as is done in the doc,则会失败:
> plot = ggplot(aes(x='timestamp', color='senderId'), data=df) + geom_density()
ValueError: `dataset` input should have multiple elements.
尝试使用更大的数据集(~40K事件):
> plot = ggplot(aes(x='timestamp', color='senderId'), data=df) + geom_density()
numpy.linalg.linalg.LinAlgError: singular matrix
有什么想法吗?这些错误在SO上有一些答案,但似乎都没有。
这是我想要的那种图表(来自ggplot' doc):
答案 0 :(得分:0)
使用较小的数据集:
> plot = ggplot(aes(x='timestamp', color='senderId'), data=df) + geom_density()
ValueError: `dataset` input should have multiple elements.
这是因为有些senderId
只有一行。
使用更大的数据集:
> plot = ggplot(aes(x='timestamp', color='senderId'), data=df) + geom_density()
numpy.linalg.linalg.LinAlgError: singular matrix
这是因为对于某些senderId
,我在完全相同的timestamp
处有多行。 ggplot
不支持此功能。我可以通过使用更精细的时间戳来解决它。