How to use groupby while plotting the graph?

I have a dataset which I used groupby operation to count and group data. it would be like this:
df=data.groupby(data.col1)[‘col2’].count(), col2, data=df)
it keeps giving errors. If I do it this way,
it would plot what I want. So what am I missing here?