Jun-20-2022, 05:02 PM
(This post was last modified: Jun-20-2022, 05:02 PM by deanhystad.)
numpy arrays have a data type. All elements in the array are that type. You cannot make a numpy array that has strings and integers.
That said, you can have a numpy array of structures.
That said, you can have a numpy array of structures.
import numpy as np from numpy.lib import recfunctions arr1 = np.array([1, 2, 3, 4, 5, 6, 7]) arr2 = np.array(["n", "b", "c", "y", "f", "j", "p"]) l = recfunctions.merge_arrays((arr1, arr2)) print(l)
Output:[(1, 'n') (2, 'b') (3, 'c') (4, 'y') (5, 'f') (6, 'j') (7, 'p')]