This document lists 44 questions about various numpy array operations and manipulations. It covers topics such as importing numpy, creating arrays, extracting/replacing array items based on conditions, reshaping arrays, stacking arrays, generating custom sequences, common/unique items between arrays, mean/median/standard deviation, normalizing, sorting, filtering, grouping, correlations and converting between array types. The goal is to provide examples of basic to advanced numpy array usage and functionality.
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 ratings0% found this document useful (0 votes)
46 views2 pages
Ex 1 A Numpy Ex
This document lists 44 questions about various numpy array operations and manipulations. It covers topics such as importing numpy, creating arrays, extracting/replacing array items based on conditions, reshaping arrays, stacking arrays, generating custom sequences, common/unique items between arrays, mean/median/standard deviation, normalizing, sorting, filtering, grouping, correlations and converting between array types. The goal is to provide examples of basic to advanced numpy array usage and functionality.
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 1 a: Basic Numpy Exercise:
1. Import numpy as np and see the version
2. How to create a 1D array? 3. How to create a boolean array? 4. How to extract items that satisfy a given condition from 1D array? 5. How to replace items that satisfy a condition with another value in numpy array? 6. How to replace items that satisfy a condition without affecting the original array? 7. How to reshape an array? 8. How to stack two arrays vertically? 9. How to stack two arrays horizontally? 10. How to generate custom sequences in numpy without hardcoding? 11. How to get the common items between two python numpy arrays? 12. How to remove from one array those items that exist in another? 13. How to get the positions where elements of two arrays match? 14. How to extract all numbers between a given range from a numpy array? 15. How to make a python function that handles scalars to work on numpy arrays? 16. How to swap two columns in a 2d numpy array? 17. How to swap two rows in a 2d numpy array? 18. How to reverse the rows of a 2D array? 19. How to reverse the columns of a 2D array? 20. How to create a 2D array containing random floats between 5 and 10? 21. How to print only 3 decimal places in python numpy array? 22. How to pretty print a numpy array by suppressing the scientific notation (like 1e10)? 23. How to limit the number of items printed in output of numpy array? 24. How to print the full numpy array without truncating 25. How to import a dataset with numbers and texts keeping the text intact in python numpy? 26. How to extract a particular column from 1D array of tuples? 27. How to convert a 1d array of tuples to a 2d numpy array? 28. How to compute the mean, median, standard deviation of a numpy array? 29. How to normalize an array so the values range exactly between 0 and 1? 30. How to compute the softmax score? 31. How to find the percentile scores of a numpy array? 32. How to insert values at random positions in an array? 33. How to find the position of missing values in numpy array? 34. How to filter a numpy array based on two or more conditions? 35. How to drop rows that contain a missing value from a numpy array? 36. How to find the correlation between two columns of a numpy array? 37. How to get the second largest value of an array when grouped by another array? 38. How to sort a 2D array by a column 39. How to find the most frequent value in a numpy array? 40. How to find the position of the first occurrence of a value greater than a given value? 41. How to replace all values greater than a given value to a given cutoff? 42. How to get the positions of top n values from a numpy array? 43. How to compute the row wise counts of all possible values in an array? 44. How to convert an array of arrays into a flat 1d array?