我正在尝试可视化这种形式的数据:
timestamp senderId
0 735217 106758968942084595234
1 735217 114647222927547413607
2 735217 106758968942084595234
3 735217 106758968942084595234
4 735217 114647222927547413607
5 etc...
geom_density
如果我不分开就可以senderId
s:
df = pd.read_pickle('data.pkl')
df.columns = ['timestamp', 'senderId']
plot = ggplot(aes(x='timestamp'), data=df) + geom_density()
print plot
结果看起来符合预期:
但是如果我想展示senderId
分别,正如文档中所做的那样 http://ggplot.yhathq.com/docs/geom_density.html, 它失败:
> 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
任何想法?对于这些错误,有一些答案,但似乎没有一个相关。
这是我想要的图表(来自 ggplot 的文档):