-3

I am working on facebook recruitment Human or bot dataset.

bids_train.groupby(['outcome','merchandise'])['bid_id'].count()

This is the pandas series I want to plot

I know how to do it using seaborn but can't seem to figure out how to plot it using matplotlib. Just a little help will do.

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158

1 Answers1

0

first, lets put your dataframe in a variable

df = bids_train.groupby(['outcome','merchandise'])['bid_id'].count()

now, there's a shortcut to using matplotlib from a dataframe without seaborn , so this should work

df.plot.bar()

if you want to write your own matplotlib code, here's a sample based on the docs

import matplotlib.pyplot as plt

ind = range(len(df.index))
plt.bar(ind, df.values)
plt.xticks(ind, df.index, rotation='vertical')
Aviad Rozenhek
  • 2,259
  • 3
  • 21
  • 42
  • Thank you, it did work. But I was wondering if I can plot it with 'outcome' as the hue. I checked the matplotlib documentation and I didn't found anything related to that. They all lead to seaborn in someway. – Surya kant Oct 29 '20 at 20:45
  • @SuryaK seaborn does save you a lot of trouble writing complex matplotlib code. whats the issue with using seaborn? – Aviad Rozenhek Oct 29 '20 at 20:46
  • There's no issue, I was just curious. – Surya kant Oct 29 '20 at 20:47