#140 Basic pieplot with panda




Here is a first pieplot example using python and the panda library.



Pieplots are a highly unadvised way to represent data. Read the intro of the pieplot section to learn more.





# library
import pandas as pd

# --- dataset 1: just 4 values for 4 groups:
df = pd.DataFrame([8,8,1,2], index=['a', 'b', 'c', 'd'], columns=['x'])

# make the plot
df.plot(kind='pie', subplots=True, figsize=(8, 8))

With Panda you can easily make 2 pieplots for 2 groups:

# library 
import pandas as pd 

# --- dataset 2: 3 columns and rownames
df = pd.DataFrame({'var1':[8,3,4,2], 'var2':[1,3,4,1]}, index=['a', 'b', 'c', 'd'] )

# make the multiple plot
df.plot(kind='pie', subplots=True, figsize=(16,8))

Leave a Reply

Your email address will not be published.