The problem: I have a 3-D Numpy Array:
X
X.shape: (1797, 2, 500)
z=X[..., -1]
print(len(z))
print(z.shape)
count = 0
for bot in z:
print(bot)
count+=1
if count == 3: break
Above code yields following output:
1797
(1797, 2)
[23.293915 36.37388 ]
[21.594519 32.874397]
[27.29872 26.798382]
So, there are 1797 data points - each with a X and a Y coordinate and, there are 500 iterations of these 1797 points.
I want a DataFrame such that:
Index Column | X-coordinate | Y-coordinate
0 | X[0][0][0] | X[0][1][0]
0 | X[1][0][0] | X[1][1][0]
0 | X[2][0][0] | X[2][1][0]
('0') 1797 times
1 | X[0][0][1] | X[0][1][1]
1 | X[1][0][1] | X[1][1][1]
1 | X[2][0][1] | X[2][1][1]
('1' 1797 times)
.
.
.
and so on
till 500
I tried techniques mentioned here, but numpy/pandas is really escaping me:
- How To Convert a 3D Array To a Dataframe
- How to transform a 3d arrays into a dataframe in python
- Convert numpy array to pandas dataframe
- easy multidimensional numpy ndarray to pandas dataframe method?
- numpy rollaxis - how exactly does it work?
Please help me out. Hope I am adhering to the question-asking discipline.