VMan
VMan

Reputation: 45

How to convert 4 dimensional array into 2 dimensions and save as csv in python

I have a 4 dimensional array with shape (1, 2000, 102, 32)

I would like to convert it to (64000,102) 64000 is based on (2000*32).

Then store it in csv file.

Thanks

Upvotes: 2

Views: 2888

Answers (1)

Kannappan Sirchabesan
Kannappan Sirchabesan

Reputation: 1382

Does ordering of the dimensions matter? If not, you can just use numpy reshape function. Example is below.

import numpy as np
a=np.zeros((1, 2000, 102, 32))
print(a.shape)
b=a.reshape(64000,102) 
print(b.shape)

checkout csv module on how to write it to csv

Upvotes: 2

Related Questions