Plotting event density in Python with ggplot and pandas
<p>I am trying to visualize data of this form:</p>

<pre><code>  timestamp               senderId
0     735217  106758968942084595234
1     735217  114647222927547413607
2     735217  106758968942084595234
3     735217  106758968942084595234
4     735217  114647222927547413607
5     etc...
</code></pre>

<p><code>geom_density</code> works if I don't separate the <code>senderId</code>s:</p>

<pre><code>df = pd.read_pickle('data.pkl')
df.columns = ['timestamp', 'senderId']
plot = ggplot(aes(x='timestamp'), data=df) + geom_density()
print plot
</code></pre>

<p>The result looks as expected:</p>

<p><a href="https://i.stack.imgur.com/fdgTx.png" rel="nofollow"><img src="https://i.stack.imgur.com/fdgTx.png" alt="density plot"></a></p>

<p><strong>However if I want to show the <code>senderId</code>s separately, <a href="http://ggplot.yhathq.com/docs/geom_density.html" rel="nofollow">as is done in the doc</a>, it fails:</strong></p>

<pre><code>&gt; plot = ggplot(aes(x='timestamp', color='senderId'), data=df) + geom_density()
ValueError: `dataset` input should have multiple elements.
</code></pre>

<p><strong>Trying out with a larger dataset (~40K events):</strong></p>

<pre><code>&gt; plot = ggplot(aes(x='timestamp', color='senderId'), data=df) + geom_density()
numpy.linalg.linalg.LinAlgError: singular matrix
</code></pre>

<p><strong>Any idea?</strong> There are some answers on SO for those errors but none seems relevant.</p>

<p>This is the kind of graph I want (from ggplot's doc):</p>

<p><a href="https://i.stack.imgur.com/7VSZA.png" rel="nofollow"><img src="https://i.stack.imgur.com/7VSZA.png" alt="density plot"></a></p>