144k views
4 votes
Write a Pandas program to import excel data (coalpublic2013.xlsx) into a dataframe and draw a bar plot where each bar will represent one of the top 10 production.

1 Answer

3 votes

Answer:

import pandas as pd

import numpy as np

import matplotlib.pyplot as plt

df = pd.read_excel('coalpublic2013.xlsx')

sorted_by_production = df.sort_values(['Production'], ascending=False).head(10)

sorted_by_production['Production'].head(10).plot(kind="bar")

plt.show()

Step-by-step explanation:

The python program plot a bar chart of the top ten productions in the excel worksheet. The excel file is read in as a pandas dataframe, sorted in descending order and the first ten of the dataframe is plotted as a bar plot.

User Douglasrcjames
by
6.0k points