pie chart python pandas 1

pie chart python pandas

df = pd.DataFrame({'mass': [0.330, 4.87 , 5.97],
                   'radius': [2439.7, 6051.8, 6378.1]},
                    index = ['Mercury', 'Venus', 'Earth'])

plot = df.plot.pie(y='mass', figsize=(5, 5))

Here is what the above code is Doing:
1. Create a dataframe with the data we want to plot.
2. Call the plot.pie() method on the dataframe.
3. Pass in the column we want to plot (y=’mass’)
4. Pass in the figsize parameter to set the size of the pie chart.

Similar Posts