0% found this document useful (0 votes)
6 views3 pages

Employee Salary Graphs and DataFrames

Python code

Uploaded by

saadmunafshaikh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

Employee Salary Graphs and DataFrames

Python code

Uploaded by

saadmunafshaikh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Experiment No.

16
Q. WAP to display employee id number on X axis and their salaries on y-axis in the form of
a bar graph.
Program:
import [Link] as plt
# take employee ids and salaries for sales deptt.
x=[101,102,103,104,105]
y=[5000,6000, 4500,6000,8000]
# take employee ids and salaries for production deptt.
x1=[106,107,108,109,110]
y1=[10000,15000, 18000, 12000,8000]
# create bar graph
[Link](x,y,label="Clerks",color="blue")
[Link](x1,y1,label="Manager",color="yellow")
# set the label and legends
[Link]("employee id")
[Link]("salary")
[Link]("Company")
[Link]()
#display
[Link]()

Output:
Q. WAP to display pie chart showing percentage of employees in a department of a company
Program:
import [Link] as plot
# take percentage of employees
slices=[30,20,30,20]
# department names
deptt=["purchase", "management","HR", "accounts"]
# colors of departments
cols=["yellow","green", "red","blue"]
# create piechart
[Link](slices, labels=deptt, colors=cols,
startangle=180,explode=(0,0.2,0,0),shadow=True,
autopct="%.1f%%")
[Link](" RCOE")
[Link]()
#display
[Link]()

Output:
Post Lab Question:
Q1. Write a program to display first five elements of a data frame?
Program:
import pandas as pd
# Create a Pandas DataFrame
data = {'Name': ['John', 'Sara', 'Mike', 'Julia', 'David'],
'Age': [25, 30, 35, 40, 45],
'City': ['New York', 'Chicago', 'San Francisco', 'Los
Angeles', 'Boston']}
df = [Link](data)
# Display the first five elements of the DataFrame
print([Link]())
Output:

Q2. Write a program to display last five elements of a data frame?


Program:
import pandas as pd
# Create a sample data frame
data = {'Name': ['Alice', 'Bob', 'Charlie', 'David', 'Emily',
'Frank'],
'Age': [25, 30, 35, 40, 45, 50],
'Salary': [50000, 60000, 70000, 80000, 90000, 100000]}
df = [Link](data)
# Display the last five elements of the data frame
print([Link]())
Output:

You might also like