- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoadingDataFromFile.py
More file actions
Latest commit
17 lines (14 loc) · 584 Bytes
/
Copy pathLoadingDataFromFile.py
File metadata and controls
17 lines (14 loc) · 584 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
importnumpyasnp
#Reading Array From TxT File
arr=np.genfromtxt("ReadingFromFile.txt",delimiter=',')
arr=arr.astype('int32') #Otherwise print as float
print(arr)
### Boolean Masking and Advanced Indexing
print(arr>3) #Iterates over the array and return True if the element is greater than 3 otherwise false
print(arr[arr>3]) #Iterates over the array and store the index where the given comparision operator is satisfied
print(np.any(arr>8,axis=0))
print(np.all(arr>8,axis=0))
print((arr>3) & (arr<8))
#Indexing with list
a=np.array([1,2,3,4,5,6,7,8,9])
print(a[[0,2,5,7]])