w3resource

Pandas Excel: Find a specific MSHA ID


Write a Pandas program to import given excel data (coalpublic2013.xls ) into a dataframe and find a specific MSHA ID. Go to Excel data

Sample Solution:

Python Code :

import pandas as pd
import numpy as np
df = pd.read_excel('E:\coalpublic2013.xlsx')    
df[df["MSHA ID"]==102901].head()

Sample Output:

   Year  MSHA ID         Mine_Name  Production  Labor_Hours
8  2013   102901  Shoal Creek Mine           0        12396
9  2013   102901  Shoal Creek Mine     1453024      1237415	                                       

Excel Data:

coalpublic2013.xlsx:


Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a Pandas program to create a subtotal of "Labor Hours" against MSHA ID from the given excel data (coalpublic2013.xls ).
Next: Write a Pandas program to import excel data (coalpublic2013.xlsx ) into a dataframe and find details where "Labor Hours" > 20000.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.