Appending to and removing from numpy arrays

Urs Thuermann urs at isnogud.escape.de
Wed Jun 10 06:01:43 EDT 2020


Hi,

is it possible to append data to or remove data from numpy arrays like
Python lists?  I have some code where I currently use lists and often
do things like

    a.append(elem)
    a += b
    del a[:-n]

I am thinking of changing to numpy arrays but it seems I cannot modify
numpy arrays like this in-place, but instead I need to create a new
array and assign that:

    a = np.append(a, elem)
    a = np.append(a, b)
    a = a[-n:]

Or do I miss something here?

urs


More information about the Python-list mailing list