Pandas plot mean values from corresponding unique id values
<p>This is my csv file. I want to find the mean cost for each unique ids. </p>

<p>so for example: id 1, mean cost should be 20.</p>

<pre><code>id,cost
1,10 
1,20
1,30
2,40
2,50
</code></pre>

<p>I got the output right with:</p>

<pre><code>df.groupby(['id'])['cost'].mean()
id
1    20
2    45
Name: cost, dtype: int64
</code></pre>

<p>But i dont know how to plot such that x-axis is the id (1,2) and y axis as the mean values (20,45). </p>

<p>The below code made the mean to be the x-axis (should be on y-axis) while the y-axis is only until 1 (should be 2 and should be the x-axis). </p>

<pre><code>df.groupby(['id'])['cost'].mean().hist()
</code></pre>

<p><a href="https://i.stack.imgur.com/tpP7j.png" rel="nofollow"><img src="https://i.stack.imgur.com/tpP7j.png" alt="enter image description here"></a></p>

<p>Piggybacking off of Psidom's comment...</p>

<pre><code>df.groupby('id').mean().plot(kind='bar')
</code></pre>

<p><a href="https://i.stack.imgur.com/Kga1c.png" rel="nofollow"><img src="https://i.stack.imgur.com/Kga1c.png" alt="enter image description here"></a></p>

<hr>

<pre><code>In [108]: df
Out[108]: 
   id  cost
0   1    10
1   1    20
2   1    30
3   2    40
4   2    50
</code></pre>

python pandas matplotlib plot