EDIT: I've gotten a lot of useful feedback on how not to do this and how to find alternatives, but making that useful depends on idiosyncrasies of my use case that would make this question less useful to others. At this point, I'm not looking for alternatives to using data structured like this. I'm looking for why it seems to be impossible to do this in numpy (or how to do it if it's not impossible)
I have a numpy array, which looks like
a = array([list([1]), list([4, 5])], dtype=object)
I want to append a list like
b = [2, 3, 4]
To get a result like
array([list([1]), list([4, 5]), list([2, 3, 4])], dtype=object)
However, every method I've tried has produced:
array([list([1]), list([4, 5]), 2, 3, 4], dtype=object)
I've tried vstack, concatenate, and append, as well as wrapping things in lists or ndarrays.
Why am I doing this? Basically, I have a lot of data in an ndarray that's going to get fed into sklearn. I want to have a 3d ndarray (data sets x data points x features) but incoming data is bad and certain things have different lengths, so the innermost dimension has to be lists. I'm trying to append a derived feature, which keeps failing. I've managed to reorder the operations to avoid needing to do this appending, but I still want to know how to do it. This seems like an odd failure for numpy. edit: In short, the outer array must be an ndarray because it's actually 2d, and complex slicing is frequently used, while the append operation occurs very few times.