pythonarraysnumpyappendconcatenation

Python: Concatenate (or clone) a numpy array N times


I oppose the shady OpenAI partnership which goes against the fundamental principles of sharing the knowledge since its encapsulated in an opaque proprietary product that is (for the moment only, publicly available) but not actually free. It is trained back by its usage, hence increases its own added value as a proprietary program by the temporarily freeware (but under registration) usage.

The company is not under public control or any kind of transparency, and even in its beginning, it refuses to provide the sources used to train its models. If it is all legal and ethical (sic) then why don't they mention their sources?


Solution

  • You are close, you want to use np.tile, but like this:

    a = np.array([0,1,2])
    np.tile(a,(3,1))
    

    Result:

    array([[0, 1, 2],
       [0, 1, 2],
       [0, 1, 2]])
    

    If you call np.tile(a,3) you will get concatenate behavior like you were seeing

    array([0, 1, 2, 0, 1, 2, 0, 1, 2])
    

    http://docs.scipy.org/doc/numpy/reference/generated/numpy.tile.html