NumPy Advanced Functional Analysis and Transformation
import numpy as np
# Dataset: Scores of 5 students in 4 subjects (rows: students, cols: subjects)
scores = [Link]([
[85, 78, 92, 88],
[70, 65, 80, 75],
[90, 88, 95, 93],
[60, 72, 68, 65],
[88, 85, 90, 86]
])
NumPy Advanced Knowledge Test - Functional and Statistical Analysis
Dataset:
Scores of 5 students in 4 subjects
1. Use np.apply_along_axis to calculate the average score per student.
2. Use np.apply_along_axis to calculate the range (max - min) of each subject.
3. Identify the student with the highest total score using [Link].
4. Normalize the scores per subject using broadcasting.
5. Find which student showed the most improvement between subject 1 and 4.
6. Replace all scores below the subject-wise average with the string 'low'.
7. Count how many students scored above 85 in all subjects using boolean masking.
8. Use [Link] to convert scores > 90 to 'excellent', 75-90 to 'good', and below 75 to
'average'.
9. Sort the entire array row-wise (student-wise) using [Link].
10. Find the correlation coefficient between subject 1 and subject 4.
11. Calculate variance and standard deviation for each subject.
12. Create a mask to highlight students who scored above average in more than 2
subjects.
13. Apply a function using [Link] to curve each score: add 5 if < 85, else add 2.
14. Calculate the z-score of each score per subject using broadcasting.
15. Replace the lowest score in each student's row with zero.
16. Use [Link] to bound all scores between 70 and 90.
17. Identify all students who scored the same in at least two subjects.
18. Count how many times each score appears using [Link] with return_counts.
19. Compute the average of the top 2 scores in each row.
20. Add a new subject column with random scores between 60-100.