Python  Print a 5x5x3 numpy array as three 5x5 numpy arrays?
By : Isoft test
Date : March 29 2020, 07:55 AM
seems to work fine When I print my 5x5x3 numpy array, it prints as 5 5x3 arrays. , Something like this should work: code :
In [1]: import numpy as np
In [2]: a = np.array([[[1,2,3], [3,4,3]],[[5,6,3], [7,8,3]]])
In [3]: a.shape
Out[4]: (2, 2, 3)
In [4]: for i in range(a.shape[1]):
...: print(a[:,:,i])
...:
[[1 3]
[5 7]]
[[2 4]
[6 8]]
[[3 3]
[3 3]]

remove specific elements from numpy array [PREVIOUSLY] selecting elements by data type from a numpy array
By : Bonfire
Date : March 29 2020, 07:55 AM
hop of those help? Note that numpy.select takes an arbitrary condition list. You could use the condition isinstance(x, str) to check if x is of type str

How to print array data that I just compressed using numpy zip()
By : Francis Poissant
Date : March 29 2020, 07:55 AM
wish help you to fix your issue I am trying to figure out how to see the the data from the zipped content. The scenario is as follows in the code: , zip of a tuple of lists is a kind of list transpose: code :
In [83]: x=[1,2,3]
...: y=[4,5,6]
...: z=[7,8,9]
...:
In [84]: zip(x,y,z)
Out[84]: <zip at 0xaf79f84c>
In [85]: list(zip(x,y,z))
Out[85]: [(1, 4, 7), (2, 5, 8), (3, 6, 9)]
In [86]: np.array(list(zip(x,y,z)))
Out[86]:
array([[1, 4, 7],
[2, 5, 8],
[3, 6, 9]])
In [87]: np.array(zip(x,y,z))
Out[87]: array(<zip object at 0xaf75d8cc>, dtype=object)
In [88]: np.stack((x,y,z)) # same as np.array((x,y,z))
Out[88]:
array([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])
In [89]: np.stack((x,y,z),axis=1)
Out[89]:
array([[1, 4, 7],
[2, 5, 8],
[3, 6, 9]])
In [92]: for i,j,k in zip(x,y,z):
...: print(i,j,k,i+j+k)
...:
1 4 7 12
2 5 8 15
3 6 9 18
In [97]: data = np.array(zip(x,y,z))
In [98]: data
Out[98]: array(<zip object at 0xabee412c>, dtype=object)
In [99]: data[()]
Out[99]: <zip at 0xabee412c>
In [100]: list(data[()])
Out[100]: [(1, 4, 7), (2, 5, 8), (3, 6, 9)]

print row from a data in numpy structured array
By : ikar0
Date : March 29 2020, 07:55 AM
To fix the issue you can do i have the next structured array in numpy: , You can do the following: code :
matrix = np.array([('b8:27:eb:07:65:ad', '0.130s', 255),
('b8:27:eb:07:65:ad', '0.120s', 215),
('b8:27:eb:07:65:ad', '0.130s', 168)],
dtype=[('col1', '<U17'),
('col2', '<U17'),
('col3', '<i4')])
for row in matrix:
if row['col3'] < 254:
print(row)

Using Dictionary in Numpy Array dosent make that array to have single Data Type
By : Shashi Kant Rao
Date : September 12 2020, 07:00 AM
Hope that helps If the desired datatype for the array is not given, then the type "will be determined as the minimum type required to hold the objects in the sequence." In the first case, the minimum type is str, because each item can be converted to a string. The new array holds strings. code :
np1 = np.array([1, '2' , True], dtype=object)
type(np1[0]))
#<class 'int'>
type(np1[1]))
#<class 'str'>
type(np1[2]))
#<class 'bool'>

