0

I'm trying to crate a bar plot where the x-axis is column1 in my dataFrame (lets said it called "A" and it contains strings) and the y-axis is the second column (named "B" and contains integers). I want to create a the plot and get the data from the relevant columns, and to see the x-axis labels as the strings that are in the dataFrame.

how can I do this?

1

1 Answer 1

1

A simple example:

import pylab as plt
import pandas as pd
from random import sample

atype = list('abc'*2)
asize = sample(xrange(100), 6)

df = pd.DataFrame({'type': atype, 'size': asize})
df_grouped = df.groupby('type').sum() # sum sizes for same types
df_grouped.plot(kind='bar')
plt.show()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.