0% found this document useful (0 votes)
3 views2 pages

EX. NO: 5 Numpy Structured Arrays: Register Number: 2127240501011

The document outlines a procedure to filter and sort employees with a salary greater than 25,000 using NumPy's structured arrays. It includes an algorithm, source code, and a successful execution result. The program filters the employee data and sorts the filtered results by name.

Uploaded by

AnanyaKannan
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)
3 views2 pages

EX. NO: 5 Numpy Structured Arrays: Register Number: 2127240501011

The document outlines a procedure to filter and sort employees with a salary greater than 25,000 using NumPy's structured arrays. It includes an algorithm, source code, and a successful execution result. The program filters the employee data and sorts the filtered results by name.

Uploaded by

AnanyaKannan
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
You are on page 1/ 2

EX.

NO: 5 NUMPY STRUCTURED ARRAYS

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')]

employee_data = np.array([('Stefan Salvatore', 'HR', 'Manager',


28000),
('Damon Salvatore', 'IT', 'Developer',
23000),
('Elena Gilbert', 'Sales', 'Execuitive',
26000),
('Klaus Santa', 'Finance', 'Analyst',
35000),
('Elijah Browne', 'HR', 'Executive',
24000)], dtype = employee_dtype)
filtered_employees = employee_data[employee_data['salary'] > 25000]

Register number: 2127240501011 Page: 9


sorted_employees = np.sort(filtered_employees, order = 'name')
print(filtered_employees)
print("\n")
print(sorted_employees)

SAMPLE INPUT AND OUTPUT

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.

Register number: 2127240501011 Page: 10

You might also like