Python NumPy Programs

NumPy is a library for the Python programming language, adding support for large, multi-dimensional arrays and matrices, along with a large collection of high-level mathematical functions to operate on these arrays.

This section contains the solved programs on Python NumPy, practice these programs to learn the concept of Python NumPy. These programs contain the solved code, explanation, and output used in the Python NumPy programs.

Search a program from the list of Python NumPy programs.

List of Python NumPy Programs

  1. Convert pandas dataframe to NumPy array
  2. What does -1 mean in numpy reshape?
  3. How can the Euclidean distance be calculated with NumPy?
  4. Convert a NumPy array into a CSV file
  5. How to get the n-largest values of an array using NumPy?
  6. How do I access the ith column of a NumPy multidimensional array?
  7. How do I print the full NumPy array, without truncation?
  8. Most efficient way to map function over numpy array
  9. How to count the occurrence of a certain item in a ndarray?
  10. Is there a NumPy function to return the first index of something in an array?
  11. Pretty-print a NumPy array without scientific notation and with given precision
  12. What does numpy.random.seed() do?
  13. Sorting arrays in NumPy by column
  14. How do I read CSV data into a record array in NumPy?
  15. Convert 2D float array to 2D int array in NumPy
  16. Most efficient way to reverse a NumPy array
  17. NumPy array initialization (fill with identical values)
  18. How to remove NaN values from a given NumPy array?
  19. How do I use np.newaxis?
  20. NumPy matrix vector multiplication
  21. Convert a tensor to numpy array in Tensorflow?
  22. How to remove specific elements in a numpy array?
  23. Better way to shuffle two numpy arrays in unison
  24. Convert array of indices to one-hot encoded array in NumPy?
  25. Create numpy matrix filled with NaNs
  26. How to create a numpy array of all True or all False?
  27. Transposing a 1D NumPy Array
  28. NumPy Array: Moving Average or Running Mean
  29. How to calculate percentiles in NumPy array?
  30. Is it possible to use numpy.argsort() in descending order?
  31. How to Convert List of Lists to NumPy Array?
  32. Find unique rows in a NumPy array
  33. How to check whether a numpy array is empty or not?
  34. Replace all elements of Python NumPy Array that are greater than some value
  35. How to add a new row to an empty NumPy array?
  36. Extracting specific columns in NumPy array
  37. NumPy: Get random set of rows from 2D array
  38. 'Cloning' row or column vectors
  39. How to flatten only some dimensions of a NumPy array?
  40. numpy.mean() vs numpy.average() in NumPy
  41. Concatenate a NumPy array to another NumPy array
  42. How to split data into 3 sets (train, validation and test)?
  43. How to count the number of true elements in a NumPy bool array?
  44. Add row to a NumPy array
  45. How do you get the magnitude of a vector in NumPy?
  46. What is the inverse function of zip?
  47. NumPy: Divide each row by a vector element
  48. Find the most frequent value in a NumPy array
  49. How to convert an array of strings to an array of floats in NumPy?
  50. How to index every element in a list except one?
  51. Add single element to array in numpy
  52. Detect if a NumPy array contains at least one non numeric value
  53. Convert numpy array to tuple
  54. NumPy: How to iterate over columns of array?
  55. NumPy: How to return 0 with divide by zero?
  56. Finding local maxima/minima with NumPy in a 1D NumPy array
  57. How to install SciPy and NumPy using pip?
  58. How to get the index of a maximum element in a NumPy array along one axis?
  59. How to write a multidimensional array to a text file?
  60. Fast check for NaN in NumPy
  61. Generate random array of floats between a range
  62. How do you use the ellipsis slicing syntax?
  63. What does 'three dots' mean when indexing what looks like a number?
  64. How to find the length (or dimensions, size) of a NumPy matrix?
  65. How to select elements of an array given condition?
  66. Test if NumPy array contains only zeros
  67. NumPy selecting specific column index per row by using a list of indexes
  68. How can I remove Nan from list NumPy array?
  69. How to determine whether a column/variable is numeric or not in Pandas/NumPy?
  70. NumPy Machine Epsilon
  71. Multiple Linear Regression
  72. NumPy: function for simultaneous max() and min()
  73. In-place type conversion of a NumPy array
  74. Best way to assert for numpy.array() equality?
  75. Rank items in an array using NumPy, without sorting array twice
  76. Subsampling every nth entry in a NumPy array
  77. How does multiplication differ for NumPy Matrix vs Array classes?
  78. What is the difference between NaN and None?
  79. How to delete a batch of rows of a NumPy array simultaneously?
  80. Python - How to remove specific elements from a NumPy array?
  81. Stack summing vectors to numpy 3d array
  82. How to sum by year using NumPy?
  83. How to turn a 3d numpy array into a pandas dataframe of numpy 1d arrays?
  84. How to use numpy.arange() with pandas Series?
  85. Select records of specific data type from numpy recarray
  86. Calculating a rolling (weighted) average using numpy
  87. Converting a 3D NumPy array to coordinates and values
  88. How to add a 4x4 matrix values into a 6x6 matrix using numpy?
  89. How to print a unit matrix?
  90. NumPy: How to make a moving(growing) sum of table contents without a for loop?
  91. Solving Systems of Linear Equations with Python's NumPy
  92. How to calculate cumulative normal distribution?
  93. How can I use numpy.correlate() to do autocorrelation?
  94. How to save a list as NumPy array?
  95. numpy.logical_or() for more than two arguments
  96. How to pad NumPy array with zeros?
  97. NumPy index slice without losing dimension information
  98. What exactly does numpy.exp() do?
  99. What is the difference between i+1 and i += 1 in a for loop with NumPy?
  100. Non-repetitive random number in NumPy
  101. NumPy array assignment with copy
  102. Replacing NumPy elements if condition is met
  103. Efficiently checking if arbitrary object is NaN in NumPy?
  104. How to remove all rows in a numpy ndarray that contain non numeric values?
  105. Convert 2d numpy array into list of lists
  106. Shift elements in a NumPy array
  107. How does NumPy's transpose() method permute the axes of an array?
  108. How to get the indices list of all NaN value in NumPy array?
  109. Convert nan value to zero in NumPy array
  110. NumPy: Find first index of value fast
  111. Find the index of the k smallest values of a NumPy array
  112. Interweaving two numpy arrays
  113. Replace negative values in a numpy array
  114. Translate every element in numpy array according to key
  115. Add NumPy array as column to Pandas dataframe
  116. List to array conversion to use ravel() function
  117. What is the difference between np.mean() and tf.reduce_mean()?
  118. Calculate mean across dimension in a 2D array
  119. How to create a numpy array of arbitrary length strings?
  120. How does python numpy.where() work?
  121. How does numpy.std() method work?
  122. Is there a multi-dimensional version of arange/linspace in numpy?
  123. How to copy data from a NumPy array to another?
  124. Why does corrcoef return a matrix?
  125. Comparing numpy arrays containing NaN
  126. shuffle vs permute numpy
  127. Partition array into N chunks with NumPy
  128. Maximum allowed value for a numpy data type
  129. 'isnotnan' functionality in numpy, can this be more pythonic?
  130. Get the position of the largest value in a multi-dimensional NumPy array
  131. How do you find the IQR in NumPy?
  132. NumPy's mean() and nanmean() Methods
  133. How to make numpy.argmax() return all occurrences of the maximum?
  134. Averaging over every n elements of a NumPy array
  135. How to find the groups of consecutive elements in a NumPy array?
  136. Count all values in a matrix less than a value
  137. Concatenate (or clone) a NumPy array N times
  138. Differentiating between row and column vectors
  139. Why are 0d arrays in Numpy not considered scalar?
  140. Concatenate two NumPy arrays vertically
  141. How can I tell if NumPy creates a view or a copy?
  142. How to solve a pair of nonlinear equations?
  143. Load CSV into 2D matrix with NumPy for plotting
  144. Find out if matrix is positive definite with numpy
  145. Prepend element to numpy array
  146. Determining duplicate values in an array
  147. How to inverse a matrix using NumPy?
  148. How to perform element-wise Boolean operations on NumPy arrays?
  149. How to calculate the sum of all columns of a 2D numpy array (efficiently)?
  150. How to turn a boolean array into index array in numpy?
  151. How to upgrade NumPy?
  152. How to use numpy.savetxt() to write strings and float number to an ASCII file?
  153. How to round a numpy array?
  154. How does condensed distance matrix (cdist) work?
  155. NumPy: Creating a complex array from 2 real ones?
  156. What is an intuitive explanation of numpy.unravel_index()?
  157. Calculate average values of two given NumPy arrays
  158. Built-in range() or numpy.arange(): which is more efficient?
  159. Why is numpy's einsum faster than numpy's built in functions?
  160. NumPy: Slice of arbitrary dimensions
  161. Importing PNG files into NumPy
  162. Rearrange columns of NumPy 2D array
  163. Calculating Covariance using numpy.cov() method
  164. Set numpy array elements to zero if they are above a specific threshold
  165. Ignore divide by 0 warning in NumPy
  166. How can I 'zip sort' parallel numpy arrays?
  167. NumPy: Shuffle multidimensional array by row only, keep column order unchanged
  168. Easy way to test if each element in a numpy array lies between two values?
  169. Elegant way to perform tuple arithmetic
  170. Factorial in numpy and scipy
  171. How to zip two 1d numpy array to 2d numpy array?
  172. Are numpy arrays passed by reference?
  173. Test array values for NaT (not a time) in NumPy
  174. Array slice with comma
  175. Check whether a Numpy array contains a specified row
  176. Initialise numpy array of unknown length
  177. Interpolate NaN values in a numpy array
  178. What does numpy.gradient() do?
  179. Use numpy's any() and all() methods
  180. Sort array's rows by another array
  181. How to add items into a numpy array?
  182. NumPy minimum in (row, column) format
  183. How to swap columns in a numpy array?
  184. Check if numpy array is multidimensional or not
  185. Function to determine if two numbers are nearly equal when rounded to n significant decimal digits
  186. Check how many elements are equal in two numpy arrays?
  187. How to transform negative elements to zero without a loop?
  188. NumPy: Extract Submatrix
  189. NumPy: Subtract every row of matrix by vector
  190. NumPy: Divide row by row sum
  191. How to apply a function / map values of each element in a 2d numpy array/matrix?
  192. Slice 2d array into smaller 2d arrays
  193. How to Remove Duplicate Elements from NumPy Array?
  194. Recover dict from 0-d numpy array
  195. Difference between numpy dot() and inner() Methods
  196. Iterating over NumPy matrix rows to apply a function each?
  197. numpy.unique() method with order preserved
  198. NumPy vstack vs. column_stack

What's New (MCQs)

Comments and Discussions!

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© some rights reserved.