About 214,000 results
Open links in new tab
  1. Is arr.__len__() the preferred way to get the length of an array in ...

    @BT: I suspect at least part of the reason for __len__ vs. .length() is that all names that begin and end with double-underscores (dunders) are: 1) Reserved for language use, and 2) Allow the …

  2. How do I get the length of a list? - Stack Overflow

    Nov 11, 2009 · Besides len you can also use operator.length_hint (requires Python 3.4+). For a normal list both are equivalent, but length_hint makes it possible to get the length of a list …

  3. Find length of 2D array Python - Stack Overflow

    Jun 30, 2016 · Find length of 2D array Python. Ask Question Asked 12 years, 11 months ago. Modified 1 month ago.

  4. len () of a numpy array in python - Stack Overflow

    Mar 29, 2017 · Python maps len(obj) onto obj.__len__. X.shape returns a tuple, which does have a len - which is the number of dimensions, X.ndim . X.shape[i] selects the ith dimension (a …

  5. python - How to count items in JSON data - Stack Overflow

    Dec 5, 2014 · I need to get the number of elements from node data['result'][0]['run']. It should be 3, but I can't find how to do it in Python. It should be 3, but I can't find how to do it in Python. python

  6. python - Numpy array dimensions - Stack Overflow

    Jun 22, 2023 · Since the dimensions of a numpy array is stored as the shape attribute, getattr() can also be used. arr = np.arange(8).reshape(2,2,2) getattr(arr, 'shape') # (2, 2, 2) It's useful if …

  7. is there a way to know the length of a bytearray variable in python ...

    Mar 27, 2015 · The idiom used for this in python is len(obj), not obj.len() >>> v = 'ffff' >>> msg = bytearray(v.decode('hex')) >>> len(msg) 2 If you are creating your own class that should be …

  8. Counting array elements in Python - Stack Overflow

    Jun 29, 2016 · However, there are in fact 10 elements in this 2D array. In the case of multi-dimensional arrays, len() gives you the length of the first dimension of the array i.e. import …

  9. python - How do you get the magnitude of a vector in Numpy?

    Oct 10, 2016 · Yet another alternative is to use the einsum function in numpy for either arrays:. In [1]: import numpy as np In [2]: a = np.arange(1200.0).reshape((-1,3)) In [3]: %timeit …

  10. python - size of NumPy array - Stack Overflow

    I'm really curious why shape is an attribute of arrays and a function in the numpy model but not a method of array objects. Is there an obvious answer? Is there an obvious answer? Does it feel …

Refresh