About 178,000 results
Open links in new tab
  1. How do I declare an array in Python? - Stack Overflow

    Aug 23, 2022 · Python has an independent implementation of array() in the standard library module array " array.array() " hence it is incorrect to confuse the two. Lists are lists in python …

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

    For most C use cass of an array, a normal (non-fixed) list is the idiomatic python equivalent. This is an answer to the question, as it probably helps the the OP (who is transitting from C to …

  3. python - Is there a numpy function that allows you to specify start ...

    This solution is dangerous, in that a general user might assume that the resulting steps will always be as specified. However, consider the function with linspace(9.5, 11.6, step=.5) and the …

  4. 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?

  5. python - How do I create a list with numbers between two values ...

    Aug 16, 2013 · How do I create a list of numbers between two values? For example, a list between 11 and 16: [11, 12, 13, 14, 15, 16]

  6. python - Create numpy matrix filled with NaNs - Stack Overflow

    Oct 11, 2019 · I have the following code: r = numpy.zeros(shape = (width, height, 9)) It creates a width x height x 9 matrix filled with zeros. Instead, I'd like to know if there's a function or way to …

  7. python - How to define a two-dimensional array? - Stack Overflow

    Jul 12, 2011 · I want to define a two-dimensional array without an initialized length like this: Matrix = [][] But this gives an error: IndexError: list index out of range

  8. How to create an integer array in Python? - Stack Overflow

    Dec 7, 2009 · Python doesn't have a built-in array data structure. The closest you get to that are lists.

  9. Create list of single item repeated N times - Stack Overflow

    Apr 16, 2024 · 132 Create List of Single Item Repeated n Times in Python Depending on your use-case, you want to use different techniques with different semantics. Multiply a list for …

  10. python - How do I create a numpy array of all True or all False ...

    Jan 16, 2014 · Explanation: numpy creates arrays of all ones or all zeros very easily: e.g. numpy.ones((2, 2)) or numpy.zeros((2, 2)) Since True and False are represented in Python as …