EX. NO: 5 Numpy Structured Arrays: Register Number: 2127240501011
EX. NO: 5 Numpy Structured Arrays: Register Number: 2127240501011
DATE: 24/03/2025
AIM:
To filter employees with a salary greater than 25,000 and sort them by name using
NumPy's structured arrays.
ALGORITHM:
Step 1: Import the numpy library.
Step 2: Define a structured data type with fields (name, department, designation,
salary).
Step 3: Create a NumPy structured array with employee data.
Step 4: Filter employees with a salary greater than 25000.
Step 5: Sort the filtered employees by the name field.
Step 6: Print the list of filtered employees.
Step 7: Print the sorted list of employees.
SOURCE CODE:
import numpy as np
employee_dtype = [('name', 'U50'), ('department', 'U50'),
('designation', 'U50'), ('salary', 'f4')]
RESULT:
Thus, the program to filter employees with a salary greater than 25,000 and
sort them by name using NumPy's structured arrays has been executed
successfully.