Open
Description
I'm trying to concatenate all elements of a row into a string as follows:
np.apply_along_axis(lambda x: " ".join(map(str, x)), 1, b)
b is
[[111,111,0,0,0], [111,111,111,111,111]]
However, the result of the line is:
['111 111 0 0 0', '111 111 111 1']
It looks like np.apply_along_axis is cutting the second string to be of the same length as the first one. If I put a longer sequence first, the result is correct:
['111 111 111 111 111', '111 111 0 0 0']
So I'm guessing this is a bug?
Summary 2019-04-30 by @seberg
np.apply_along_axis
infers the output dtype from the first pass. Which can be worked around for example but the function returning an array of a correct type.
Actions:
np.apply_along_axis
could/should get adtype
kwarg (or similar, compare alsonp.vectorize
).