Python Assignment-2
Python Assignment-2
NumPy Assignment
Code Implementation:
import numpy as np
# 1. Create a 3x3 NumPy array with random integers between 10 and 100
array_3x3 = np.random.randint(10, 100, (3, 3))
print("3x3 Random Integer Array:\n", array_3x3)
Sample Output:
3x3 Random Integer Array:
[[44 89 15]
[11 54 52]
[49 45 63]]
Pandas Assignment
Code Implementation:
import pandas as pd
import numpy as np
df = pd.DataFrame(data)
# Display the first 3 rows
print("First 3 rows of the DataFrame:\n", df.head(3))
Sample Output:
First 3 rows of the DataFrame:
Name Age Department Salary
0 Alice 25.0 HR 50000.0
1 Bob 30.0 IT 60000.0
2 Charlie 22.0 HR 55000.0
Report Analysis
NumPy Observations:
Pandas Observations:
• The initial DataFrame contained missing values for Age and Salary.
• Employees with Salary > ₹50,000 were filtered.
• Data was sorted by Age in ascending order.
• Missing Age values were replaced with the mean, and rows with missing Salary were
removed.
• The average Salary for each Department was computed, with Finance having the
highest and HR the lowest.
Conclusion:
This assignment demonstrated essential data manipulation techniques using NumPy and Pandas.
NumPy was used for array operations, while Pandas provided insights into structured data.
Handling missing values, filtering, sorting, and grouping techniques were effectively applied,
showcasing real-world data analysis applications.