Python Amit
Python Amit
Python Amit
'EmployeeID': range(1,
21), 'Name': [
'Amit Kumar Singh', 'Aashu Kumar', 'Abhishek Raj', 'Gulshan
Kumar', 'Anmol Srivastava',
'Ujwal Singh', 'Tej Pratap Singh', 'Chirag Goyal', 'Siddharth
Pandey', 'Sudhanshu Yadav',
'Sourav Keshri', 'Bibhuti Singh', 'Tanishq Tiwari', 'Mukesh Kumar',
'Vikhyat Singh',
'Aditya Singh', 'Sarvesh Kumar', 'Ravi Prakash', 'Sachin Singh',
'Sanchit Mishra'
],
'Age':
[
29,
34,
22,
37,
28,
45,
31,
39,
23,
50,
33,
40,
27,
44,
32,
'Developer', 'Manager', 'Analyst', 'Developer', 'Executive',
'Specialist', 'Accountant', 'Manager', 'Director', 'Supervisor',
'Developer', 'Analyst', 'Assistant', 'Coordinator', 'Executive',
'Developer', 'Accountant', 'Supervisor', 'Manager', 'Developer'
],
'Salary': [
60000, 75000, 80000, 62000, 50000, 68000, 57000, 90000,
95000,
85000,
63000, 82000, 45000, 78000, 54000, 61000, 56000, 83000,
76000,
60000
],
'DateOfJoining': [
'2019-01-15', '2018-03-22', '2016-07-19', '2020-11-03', '2021-05-
10',
'2015-12-29', '2019-08-17', '2017-06-01', '2016-02-11', '2013-09-
23',
'2018-10-14', '2014-05-18', '2021-12-01', '2015-04-07', '2020-03-15',
'2017-08-21', '2019-11-27', '2014-01-30', '2016-12-08', '2019-04-15'
]
}
# Display the
DataFrame print(df)
Output:-
# Bar plot
plt.figure(figsize=(10, 5))
plt.bar(df.index,
df['Salary'], color='blue')
plt.title('Bar Plot of Salary')
plt.xlabel('EmployeeID')
plt.ylabel('Salary')
plt.show()
# Histogram
plt.figure(figsize=(10, 5))
plt.hist(df['Salary'], bins=10, color='green')
plt.title('Histogram of Salary')
plt.xlabel('Salary')
plt.ylabel('Frequency')
plt.show()
# Line plot
plt.figure(figsize=(10, 5))
plt.plot(df['EmployeeID'], df['Salary'], color='purple', marker='o', linestyle='-')
plt.title('Line Plot of Salary')
plt.xlabel('EmployeeID')
plt.ylabel('Salary')
plt.grid(True)
plt.show()
PROBLEM:- 2
Show the output of following syntax:
import numpy as np
import pandas as pd
df= pd.DataFrame(np.arange(12).reshape(3, 4),columns=['P', 'Q', 'R', 'S'])
df
Output:
df.drop([0, 1])
output
PROBLEM:-03
import pandas as pd
import numpy as np
# dictionary of lists
dict = {'First Score':[100, 90, np.nan, 95],
'Second Score': [30, 45, 56,
np.nan],
'Third Score':[np.nan, 40, 80,
98]} # creating a dataframe from list
df = pd.DataFrame(dict)
# using isnull()
function Print(df.isnull())
Print(df.notnull())
Print(df.fillna(0))
Print(df.fillna(method = ‘pad’))
Print(df.fillna(method = ‘bfill’))
Output:- 1.
2.
3.
4.