Pandas bar graph using original dataframe
<p>I have a pandas dataframe and I'm attempting to plot the number of subscription types purchased by gender the original dataframe resemblems</p>

<pre><code>df = 
Memb_ID   Gender   1_Month   3_Month   6_Month   1_Year
1         Male     6         0         3         0
2         Male     0         0         0         4
3         Female   0         4         3         1
4         Male     2         1         0         1
5         Female   1         4         0         2
...
</code></pre>

<p>At the moment I make a <code>temp_df</code> where I sum up the data so that I have</p>

<pre><code>temp_df = pd.DataFrame(columns=['Gender', '1_Year', '1_Month', '3_Month','6_Month'])

sex = ['Male', 'Female']
temp_df['Gender'] = sex

for i in list(temp_df.columns.values)[1:]:
    temp = [df.loc[df['Gender'] == 'Male', i].sum(),\
            df.loc[df['Gender'] == 'Female', i].sum()]
    temp_df[i] = temp

temp_df.plot(x='Gender', kind='bar', grid=True)
plt.show()
</code></pre>

<p>This fills up <code>temp_df</code> and I'm able to graph it. Is there an eloquent way of performing the same thing using just <code>df</code>?</p>

<p>You can use <code>groupby().sum()</code> to replace the <code>temp_df</code>:</p>

<pre><code>ax = df.groupby('Gender')['1_Year','1_Month','3_Month','6_Month'].sum().plot.bar(grid=True)
</code></pre>

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

python pandas plot