Pandas Excel: Find a list of employees of a specified year
Pandas: Excel Exercise-18 with Solution
Write a Pandas program to import given excel data (employee.xlsx ) into a Pandas dataframe and find a list of employees of a specified year. Go to Excel data
Sample Solution:
Python Code :
import pandas as pd
import numpy as np
df = pd.read_excel('E:\employee.xlsx')
df2 = df.set_index(['hire_date'])
result = df2["2005"]
result
Sample Output:
hire_date 2005-09-21 101 Neena Kochhar 2005-06-25 105 David Austin 2005-09-28 110 John Chen 2005-09-30 111 Ismael Sciarra 2005-12-24 116 Shelli Baida 2005-07-24 117 Sigal Tobias
Excel Data:
employee.xlsx:
Sheet-1
Sheet-2
Sheet-3
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a Pandas program to import given excel data (employee.xlsx ) into a Pandas dataframe and find a list of employees where hire_date between two specific month and year.
Next: Write a Pandas program to import given excel data (employee.xlsx ) into a Pandas dataframe and convert the data to use the hire_date as the index.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://198.211.115.131/python-exercises/pandas/excel/python-pandas-excel-exercise-18.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics