-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathb) Numpy 2.py
More file actions
53 lines (39 loc) · 1.38 KB
/
b) Numpy 2.py
File metadata and controls
53 lines (39 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# -*- coding: utf-8 -*-
"""
Created on Wed Nov 1 20:58:56 2023
@author: lEO
"""
import numpy as np
# Creating Data in NUMPY
# NP.ARANGE ----> Used to create an array with a range of numbers. We would also need to specify the apprioprate shape.
# (1) Using np.arange()
# EXAMPLE 1
array1 = np.arange(1, 101, None) # VECTOR
# EXAMPLE 2 ---> Reshape ARRAY 1
array2 = array1.reshape([4, 25]) # MATRIX
# NP.EMPTY ----> Used to create a RANDOM array of numbers.
# (2) Using np.empty()
# np.empty_like()
# EXAMPLES
array3 = np.empty((2, 5)) # NO RANGE TO RANDOMNESS
array4 = np.empty_like(array1)
array5 = np.empty_like(array2)
array6 = np.empty_like(array3)
# NP.ONES ----> Used to create ONES
# (3) Using np.ones()
# np.ones_like()
# EXAMPLES
array7 = np.ones([7,], dtype = np.int8)
array8 = np.ones_like(array1)
# NP.FULL ----> Allows you create an array with a CONSTANT of your choice
# (4) Using np.full()
# np.full_like()
# EXAMPLES
array9 = np.full((2, 6), fill_value = (6))
array10 = np.full_like(a = array1, fill_value = 2)
# NP.ZEROS ----> Used to create an array of ZEROS
# (5) Using np.zeros()
# np.zeros_like()
# EXAMPLES
array11 = np.zeros((5, 3))
array12 = np.zeros_like(a = array1)