About 630,000 results
Open links in new tab
  1. How do I create an empty array and then append to it in NumPy?

    I want to create an empty array and append items to it, one at a time. xs = [] for item in data: xs.append(item) Can I use this list-style notation with NumPy arrays?

  2. python - How do I check if a list is empty? - Stack Overflow

    432 This is the first google hit for "python test empty array" and similar queries, and other people are generalizing the question beyond just lists, so here's a caveat for a different type of …

  3. How do I get an empty list of any size in Python? - Stack Overflow

    However, this is uncommon in python, unless you actually need it for low-level stuff. In most cases, you are better-off using an empty list or empty numpy array, as other answers suggest.

  4. Initialising an array of fixed size in Python - Stack Overflow

    a = numpy.empty(n, dtype=object) This creates an array of length n that can store objects. It can't be resized or appended to. In particular, it doesn't waste space by padding its length. This is …

  5. python - How to create an empty array and append it? - Stack …

    Jun 5, 2020 · <__array_function__ internals> in concatenate(*args, **kwargs) ValueError: all the input arrays must have same number of dimensions, but the array at index 0 has 2 …

  6. How do I declare an array in Python? - Stack Overflow

    Aug 23, 2022 · There's no way to say in Python "this variable should never refer to anything other than a list", since Python is dynamically typed. * The default built-in Python type is called a list, …

  7. python - Concatenating empty array in Numpy - Stack Overflow

    Mar 29, 2014 · 4 If you wanna do this just because you cannot concatenate an array with an initialized empty array in a loop, then just use a conditional statement, e.g.

  8. How to initialize a two-dimensional array (list of lists, if not using ...

    You can arrange data in an array like structure in default Python but it's not nearly as efficient or useful as a NumPy array. Especially if you want to deal with large data sets.

  9. How to declare and add items to an array in Python

    I'm trying to add items to an array in Python. I run array = {} Then, I try to add something to this array by doing: array.append(valueToBeInserted) There doesn't seem to be an .append …

  10. python - Remove empty strings from a list of strings - Stack …

    Oct 2, 2010 · I want to remove all empty strings from a list of strings in python. My idea looks like this: while '' in str_list: str_list.remove('') Is there any more pythonic way to do this?