Sling Academy
Home/NumPy/NumPy Basic Tutorials

NumPy Basic Tutorials

This series of tutorials helps you learn the basics of NumPy through beginner-friendly articles and well-explained code examples.

1 How to Install NumPy and Set Up Your Development Environment

2 Numpy Array vs Python List: What’s the Difference?

3 How to Create and Manipulate NumPy Arrays

4 How to Perform Basic Arithmetic Operations with NumPy

5 How to Use NumPy for Simple Statistical Analysis

6 How to Index and Slice NumPy Arrays

7 How to Reshape NumPy Arrays (multiple approaches)

8 How to Convert Python Lists to NumPy Arrays and Vice Versa

9 How to Use NumPy’s Basic Mathematical Functions

10 How to Handle Missing Data in NumPy Arrays

11 How to Use Boolean Indexing in NumPy

12 How to Sort Arrays in NumPy (Basic & Advanced Techniques)

13 How to Use NumPy for Random Number Generation

14 How to Read and Write Array Data to Files with NumPy

15 How to Use NumPy’s arange, linspace, and logspace Functions

16 How to Work with Multidimensional Arrays in NumPy

17 How to Use NumPy’s Aggregate Functions (sum, min, max, mean)

18 How to Visualize Data with Matplotlib and NumPy

19 How to Use Conditional Statements with NumPy Arrays

20 How to Perform Set Operations with NumPy Arrays

21 How to Use NumPy’s Broadcasting Feature for Array Operations

22 How to Use NumPy’s datetime64 and timedelta64 Data Types

23 How to Efficiently Iterate Over NumPy Arrays

24 How to Use Basic Linear Algebra Functions in NumPy

25 How to Use NumPy for Descriptive Statistics

26 How to Handle Numerical Precision and Rounding in NumPy

27 How to Work with Complex Numbers in NumPy

28 How to Use NumPy for Basic Image Manipulation

29 How to Combine, Stack, and Split Arrays in NumPy

30 How to Use NumPy’s genfromtxt and savetxt for Data Import/Export

31 How to gracefully handle exceptions when working with NumPy

32 How to benchmark your NumPy arrays and operations

33 NumPy: How to concatenate arrays vertically and horizontally

34 NumPy: How to Join Arrays (column-wise & row-wise)

35 NumPy: How to Split an Array Vertically (row-wise)

36 NumPy: How to Split an Array Horizontally (column-wise)

37 NumPy: How to Filter an Array Based on an Array of Booleans

38 NumPy: How to Filter an Array by a Condition

39 NumPy trunc() and fix(): How to Round Down an Array of Numbers

40 NumPy power(), mod(), and remainder(): How to Perform Fast Element-Wise Array Operations

41 Working with NumPy log2(), log10(), and log() functions

42 3 Ways to Find Sum of Array Elements in NumPy

43 3 Ways to Find Product of Array Elements in NumPy

44 NumPy: Transform Cartesian Product of Arrays x and y into a Single 2D Points Array

45 NumPy: How to find unique elements in an array

46 NumPy: How to find unique rows/columns of a 2D array

47 NumPy: Generate all possible permutations of a given array

48 NumPy: Find all possible combinations of two arrays

49 NumPy: How to calculate Euclidean and Manhattan distances

50 NumPy: How to find the row indexes of several values in a 2D array

51 How to pretty print a NumPy array by suppressing the scientific notation (like 1e10)

52 NumPy: How to get indices of N smallest/largest array elements

53 Using np.einsum() to avoid explicit loops in NumPy

54 How to find closest value in NumPy array

55 How to use logical ‘and’ and ‘or’ operators with NumPy arrays

56 NumPy apply() function: Explained with examples

57 How to count elements/rows/columns of a NumPy ndarray

58 NumPy: How to group by unique values in an array

59 How to transpose a NumPy array (1D, 2D, and 3D)

60 How to save a NumPy array to a CSV file

61 How to Split an Array into N Random Sub-arrays in NumPy

62 How to Save a NumPy Array as an Image File

63 NumPy: How to insert a row/column into a 2D array

64 NumPy: How to find common values between two arrays

65 NumPy Random Seed: Explained with examples

66 NumPy: Random selection with custom probabilities

67 5 Ways to Compare Two NumPy Arrays (with Examples)

68 NumPy: How to Flatten a 2D Matrix to 1D Array in Row-Major Order

69 NumPy: How to replace negative numbers in an array with zero

70 NumPy: Replacing all array elements that satisfy condition

71 How to check if a NumPy array contains a row/sub-array

72 NumPy: Using np.newaxis and np.expand_dims to increase dimensions of array

73 NumPy: How to store multiple data types in an array

74 How to turn a nested Python list of lists into a NumPy 2D array

75 What are scalar and vector in NumPy? (5 examples)

76 Understanding numpy.int16 and numpy.uint16 types (6 examples)

77 Exploring numpy.int32 and numpy.uint32 types (4 examples)

78 Explaining numpy.int64 and numpy.uint64 types (5 examples)

79 Explaining numpy.intp and numpy.uintp types (5 examples)

80 Understanding numpy.float16 type (4 examples)

81 Explaining numpy.float32 type (4 examples)

82 Understanding numpy.float64 type (5 examples)

83 Understanding numpy.float96 and numpy.float128 types (4 examples)

84 Understanding numpy.complex64 and numpy.complex128 types (5 examples)

85 Explaining numpy.complex192 and numpy.complex256 types (6 examples)

86 Understanding ndarray.flags attribute in NumPy (5 examples)

87 Understanding ndarray.strides attribute in NumPy (5 examples)

88 Understanding ndarray.shape and ndarray.size attributes in NumPy (6 examples)

89 NumPy – Understanding ndarray.data attribute (3 examples)

90 NumPy – Understanding ndarray.itemsize attribute (4 examples)

91 NumPy ndarray.nbytes attribute (5 examples)

92 NumPy ndarray.base attribute (6 examples)

93 A detailed guide to ndarray.dtype attribute in NumPy (5 examples)

94 Using numpy.add() function (6 examples)

95 Understanding numpy.subtract() function (5 examples)

96 Working with numpy.multiply() function (4 examples)

97 A detailed guide to numpy.matmul() function (4 examples)

98 Using numpy.divide() function (4 examples)

99 Understanding numpy.logaddexp() function (5 examples)

100 Using numpy.logaddexp2() function (3 examples)

101 Using numpy.true_divide() function (4 examples)

102 Understanding numpy.floor_divide() function (5 examples)

103 Using numpy.negative() function (4 examples)

104 NumPy – Using power() and float_power() functions (4 examples)

105 Using numpy.remainder() function (5 examples)

106 Using mod(), fmod(), and divmod() functions in NumPy (6 examples)

107 Working with numpy.fabs() function (5 examples)

108 Using numpy.rint() function (4 examples)

109 Exploring numpy.sign() function (5 examples)

110 Explaining numpy.heaviside() function (4 examples)

111 NumPy – Using conj() and conjugate() functions (4 examples)

112 NumPy – Using exp() and exp2() functions (4 examples)

113 Using numpy.log() function (5 examples)

114 NumPy – Using log2() and log10() functions (4 examples)

115 Using numpy.expm1() function (5 examples)

116 Utilizing numpy.sqrt() function (4 examples)

117 Working with numpy.square() function (5 examples)

118 Using numpy.cbrt() function (4 examples)

119 Using numpy.reciprocal() function (3 examples)

120 NumPy – Using np.gcd() function (5 examples)

121 NumPy – Using np.sin() and np.arcsin() functions (4 examples)

122 NumPy: Using np.cos() and np.arccos() functions (5 examples)

123 NumPy – Understanding tan(), arctan(), and arctan2() functions (6 examples)

124 Understanding numpy.hypot() function (5 examples)

125 NumPy – Using np.sinh() and np.arcsinh() functions (4 examples)

126 NumPy – Explaining np.cosh() and np.arccosh() functions (4 examples)

127 How to use numpy.tanh() and numpy.arctanh() functions (4 examples)

128 Understanding numpy.degrees() function (4 examples)

129 Working with numpy.radians() function (5 examples)

130 Understanding numpy.deg2rad() and numpy.rad2deg() functions (4 examples)

131 Understanding numpy.bitwise_and() function (4 examples)

132 Using char.endswith() in NumPy (4 examples)

133 Using numpy.bitwise_or() function (3 examples)

134 Exploring numpy.bitwise_xor() function (4 examples)

135 Using numpy.invert() function (5 examples)

136 Understanding numpy.left_shift() function (4 examples)

137 Exploring numpy.right_shift() function (5 examples)

138 NumPy – Using greater() and greater_equal() functions (4 examples)

139 NumPy – Using less() and less_equal() functions (5 examples)

140 NumPy: Using equal() and not_equal() functions (4 examples)

141 Understanding numpy.logical_and() function (5 examples)

142 Explaining numpy.logical_or() function (4 examples)

143 Using numpy.logical_xor() function (5 examples)

144 Using numpy.logical_not() function (4 examples)

145 NumPy – Using maximum() and fmax() functions (4 examples)

146 NumPy: Utilizing minimum() and fmin() functions (4 examples)

147 Using numpy.isfinite() function (4 examples)

148 Using numpy.isinf() function (3 examples)

149 Understanding NumPy isnan() function (4 examples)

150 Using numpy.isnat() function (5 examples)

151 Using NumPy signbit() function (4 examples)

152 Understanding numpy.copysign() function (5 examples)

153 Using numpy.nextafter() function (4 examples)

154 Explaining numpy.spacing() function (5 examples)

155 Working with NumPy modf() function (4 examples)

156 How to use numpy.ldexp() function (5 examples)

157 Using numpy.frexp() function (4 examples)

158 Using numpy.floor() function (3 examples)

159 Understanding numpy.ceil() function (4 examples)

160 Working with numpy.trunc() function (7 examples)

161 NumPy – Understanding ndarray.T attribute (3 examples)

162 NumPy – Using ndarray.real attribute (4 examples)

163 NumPy – How to get the imaginary part of an array (4 examples)

164 NumPy – Using ndarray.flat attribute (5 examples)

165 NumPy ndarray.item() method (4 examples)

166 Using ndarray.tolist() method in NumPy (5 examples)

167 Using ndarray.tostring() method in NumPy (4 examples)

168 Understanding ndarray.itemset() method in NumPy (3 examples)

169 NumPy: Using ndarray.tobytes() method (4 examples)

170 Using ndarray.tofile() method in NumPy (with examples)

171 NumPy: How to use ndarray.dump() method (3 examples)

172 NumPy – Using ndarray.dumps() method (4 examples)

173 NumPy: 4 ways to disable future/depreciated warnings

174 NumPy – Using ndarray.astype() method to change data type (5 examples)

175 Understanding numpy.absolute() function (4 examples)

176 NumPy – Using ndarray.byteswap() method (4 examples)

177 Using ndarray.copy() method in NumPy (5 examples)

178 NumPy – Using ndarray.view() method (4 examples)

179 Explore ndarray.getfield() method in NumPy (5 examples)

180 Using ndarray.setflags() method in NumPy (4 examples)

181 Understanding ndarray.fill() method in NumPy (6 examples)

182 NumPy – A detailed guide to ndarray.reshape() method (4 examples)

183 Using ndarray.resize() method in NumPy (5 examples)

184 NumPy – Understanding ndarray.transpose() method through examples (4 examples)

185 Using ndarray.swapaxes() method in NumPy (3 examples)

186 Mastering NumPy ndarray.flatten() method (5 examples)

187 NumPy ndarray.ravel() method: Explained with examples (4 examples)

188 Using ndarray.squeeze() method in NumPy (4 examples)

189 NumPy ndarray.take() method (5 examples)

190 NumPy – Using ndarray.repeat() method (4 examples)

191 NumPy – Working with ndarray.put() method (6 examples)

192 Using ndarray.choose() method in NumPy (5 examples)

193 Mastering ndarray.sort() method in NumPy (5 examples)

194 Mastering ndarray.argsort() method in NumPy (4 examples)

195 Using ndarray.partition() method in NumPy (4 examples)

196 NumPy – Understanding ndarray.argpartition() method (4 examples)

197 Using ndarray.searchsorted() method in NumPy (5 examples)

198 Using ndarray.nonzero() method in NumPy (4 examples)

199 Using np.lcm() function in NumPy (4 examples)

200 Understanding ndarray.compress() method in NumPy (5 examples)

201 Using ndarray.diagonal() method in NumPy (3 examples)

202 Utilizing ndarray.max() method in NumPy (4 examples)

203 Using ndarray.min() method in NumPy (5 examples)

204 Understanding ndarray.argmin() method in NumPy (3 examples)

205 Working with ndarray.argmax() method in NumPy (4 examples)

206 NumPy – Using ndarray.ptp() method (5 examples)

207 NumPy: Using ndarray.clip() method (4 examples)

208 NumPy: Understanding ndarray.conj() method (5 examples)

209 Using ndarray.round() method in NumPy (4 examples)

210 NumPy – Using ndarray.trace() method (5 examples)

211 Using ndarray.sum() method in NumPy (6 examples)

212 Understanding ndarray.cumsum() method in NumPy (5 examples)

213 NumPy – Using ndarray.mean() method (4 examples)

214 NumPy – Using ndarray.var() method (5 examples)

215 NumPy – Understanding ndarray.std() method (4 examples)

216 NumPy: Using ndarray.prod() method (5 examples)

217 How to use ndarray.cumprod() method in NumPy (4 examples)

218 Understanding ndarray.all() method in NumPy (5 examples)

219 Exploring ndarray.any() method in NumPy (4 examples)

220 Understanding numpy.mat() function (5 examples)

221 Using numpy.asmatrix() function (4 examples)

222 Using numpy.bmat() function (5 examples)

223 Using NumPy matlib.empty() function (4 examples)

224 Using NumPy matlib.zeros() function (5 examples)

225 NumPy matlib.ones() function (4 examples)

226 Using matlib.eye() function in NumPy (5 examples)

227 Exploring matlib.identity() function in NumPy (4 examples)

228 Exploring matlib.repeat() function in NumPy (5 examples)

229 NumPy matlib.rand() function (4 examples)

230 NumPy – Using matlib.randn() function (4 examples)

231 NumPy – Using random.Generator.choice() method (5 examples)

232 NumPy: How to Generate Random Bytes (4 Examples)

233 NumPy – Understanding random.Generator.random() method (5 examples)

234 NumPy – Using random Generator.shuffle() method (4 examples)

235 Using NumPy random Generator.permutation() method (5 examples)

236 NumPy – Using random Generator.permuted() method (4 examples)

237 NumPy: How to draw samples from a Beta distribution (3 examples)

238 NumPy random Generator.binomial() method (4 examples)

239 Using NumPy random Generator.chisquare() method (5 examples)

240 NumPy: Drawing samples from the Dirichlet distribution (4 examples)

241 NumPy: How to draw samples from an exponential distribution (4 examples)

242 NumPy: Getting samples from an F distribution (3 examples)

243 NumPy – Draw samples from a Gamma distribution (4 examples)

244 NumPy: Getting samples from geometric distribution (4 examples)

245 Using NumPy random Generator.gumbel() method (4 examples)

246 NumPy: How to get samples from a Hypergeometric distribution (3 examples)

247 NumPy random Generator.laplace() method (4 examples)

248 NumPy random.Generator.logistic() method (5 examples)

249 NumPy – Using random Generator.lognormal() method (4 examples)

250 NumPy – Understanding random Generator.logseries() method (5 examples)

251 NumPy: Getting samples from a multinomial distribution (4 examples)

252 NumPy: Generate variates from a multivariate hypergeometric distribution (3 examples)

253 NumPy: Get random samples from a multivariate normal distribution (3 examples)

254 NumPy: Get samples from a negative binomial distribution (4 examples)

255 NumPy: Getting samples from a noncentral chi-square distribution (5 examples)

256 NumPy: Drawing samples from the noncentral F distribution (3 examples)

257 NumPy – Using random.Generator.normal() method (4 examples)

258 NumPy – Using random.Generator.pareto() method (5 examples)

259 NumPy: Understanding random.Generator.poisson() method (4 examples)

260 NumPy – Using random.Generator.power() method (4 examples)

261 NumPy – Using random.Generator.rayleigh() method (4 examples)

262 NumPy random.Generator.standard_cauchy() method (3 examples)

263 NumPy random.Generator.standard_exponential() method (6 examples)

264 Using random.Generator.standard_gamma() method in NumPy (5 examples)

265 Using random.Generator.standard_normal() method in NumPy (4 examples)

266 NumPy – Using random.Generator.standard_t() method (4 examples)

267 NumPy – Using random.Generator.triangular() method (5 examples)

268 NumPy – Understanding random.Generator.uniform() method (5 examples)

269 Using random.Generator.vonmises() method in NumPy (5 examples)

270 Understanding random.Generator.wald() method in NumPy (4 examples)

271 NumPy – Using random.Generator.weibull() method (5 examples)

272 Using numpy.can_cast() function (8 examples)

273 Explaining numpy.promote_types() function (5 examples)

274 Understanding NumPy ufunc.reduce() method (4 examples)

275 NumPy – Exploring ufunc.accumulate() method (5 examples)

276 NumPy – How to use ufunc.reduceat() method (4 examples)

277 Using ufunc.outer() method in NumPy (5 examples)

278 Working with ufunc.at() method in NumPy (4 examples)

279 NumPy – Understanding ufunc.nin and ufunc.nout attributes (5 examples)

280 NumPy – Using ufunc.nargs attribute (4 examples)

281 NumPy – Making use of ufunc.ntypes attribute (5 examples)

282 NumPy – What is ufuc.types attribute? (4 examples)

283 NumPy – Using ufunc.identity attribute (5 examples)

284 NumPy ufunc.signature attribute: Explained with examples