0

enter image description here

So I currently have what is above. I've managed to separate them into categories using groupby but now I would like to put them in a subplot of tables.

##open comma separated file and the columns Name, In Stock, committed, reorder point

file = pd.read_csv('Katana/InventoryItems-2022-01-06-09_10.csv',
                    usecols=['Name','In stock','Committed', 'Reorder point','Category'])

##take the columns and put them in to a list
Name = file['Name'].tolist()
InStock = file['In stock'].tolist()
Committed = file['Committed'].tolist()
ReorderPT = file['Reorder point'].tolist()
Category = file['Category'].tolist()

##take the lists and change them into appropriate type of data
inStock = [int(float(i)) for i in InStock]
commited = [int(float(i)) for i in Committed]
reorderpt = [int(float(i)) for i in ReorderPT]


##have the liss with correct data type and arrange them 
inventory = {'Name': Name,
            'In stock': inStock,
            'Committed': commited,
            'Reorder point': reorderpt,
            'Category': Category

}

##take the inventory arrangement and display them into a table
frame = DataFrame(inventory)

grouped = frame.groupby(frame.Category)

df_elec = grouped.get_group('Electronics')
df_bedp = grouped.get_group('Bed Packaging')
df_fil = grouped.get_group('Filament')
df_fast = grouped.get_group('Fasteners')
df_kit = grouped.get_group('Kit Packaging')
df_pap = grouped.get_group('Paper')
BigBen
  • 46,229
  • 7
  • 24
  • 40

1 Answers1

0

Try something along the lines of:

import matplotlib.pyplot as plt

fig,axs = plt.subplots(nrows=6,ncols=1)

for ax,data in zip(axs,[df_elec,df_bedp,df_fil,df_fast,df_kit,df_pap]):
    data.plot(ax=ax,table=True)
Alex867
  • 56
  • 6
  • Thank you for the reply! The get_group function outputs a 'styler' object. apparently I cant plot a styler object. – Carlo Clores Jan 07 '22 at 18:17
  • According to the documentation, `get_group` should return an object of the same type as the original data `groupby` was called on, so it should be a DataFrame. Maybe try sharing your data or some example data to help replicate your issue? See [this guide](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) – Alex867 Jan 07 '22 at 18:32