0

I have a doubt in numpy array concatenation.

For eg,

If I have

a = [ 1, 2, 3]
b = [4, 5, 6, 7]
c= [5, 2]

Could I concatenate arrays of different size??? If so, How could it be possible?

Dhara
  • 282
  • 1
  • 4
  • 19

1 Answers1

1

Yes, You can using numpy.concatenate

import numpy as np
a = [ 1, 2, 3]
b = [4, 5, 6, 7]
c= [5, 2]
d = np.concatenate((a, b, c))
Ruhul Amin
  • 1,751
  • 15
  • 18
  • My problem is: I want to merge numpy array as a csv file. I used : np.savetxt("output-1.csv", final_array, fmt="%3.2f"). Since"final_array" contains rows of different sizes, it doesnot works – Dhara Jan 12 '17 at 08:53
  • I want the result to be: [1,2,3,\n,4,5,6,7\n,5,2] – Dhara Jan 12 '17 at 10:43