I have a 2D numpy array of strings. I am trying to save it to a CSV file. So, the issue comes when the sizes of 1D arrays are different.
For Example:
b = [['a','b'] #size of single array = 2
['c','d']] #size of single array = 2
So, now if I try to save it using:
np.savetxt("filename.csv", b, fmt ="%s", delimiter=",")
The output csv file would be:
Col1 Col2
------- ----
a b
c d
Which is what I want, but now let's say I have a different sized 1D array.
For Example:
b = [['a','b'] #size of single array = 2
['c']] #size of single array = 1
Now, when I try to save it, then the output file is:
Col1 Col2
------- ----
['a' 'b']
['c']
Whereas I want it to be saved as:
Col1 Col2
------- ----
a b
c
Can someone help me out?