How to covert array of shape n, to n,m

Saranraj K

I'm trying convert numpy array of shape (80000,) to (80000,55) I'm having the data like below [[1212,121,121],[12,122,111]] After convert this list of list I'm getting the shape of (2,) but I wanna have shape like (2,3) how to do it.

hpaulj
In [68]: np.array([[1212,121,121],[12,122,111]] )                                                               
Out[68]: 
array([[1212,  121,  121],
       [  12,  122,  111]])
In [69]: _.shape                                                                                                
Out[69]: (2, 3)

If you are getting a shape like (2,), it's probably because some of the nested lists differ in shape. Check the dtype as well as the shape. Look at the array as well.

In [70]: np.array([[1212,121,121],[12,122,111,3]] )                                                             
Out[70]: array([list([1212, 121, 121]), list([12, 122, 111, 3])], dtype=object)

An upcoming version will add a warning:

/usr/local/bin/ipython3:1: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
  #!/usr/bin/python3

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How to index a numpy array of dimension N with a 1-dimensional array of shape (N,)

分類Dev

Combining (m,m,n) arrays of the lists into an (m,m,n) array

分類Dev

For a bigger-than-memory dask array of size=(M, N): How to re-chunk from chunks=(1, N) to chunks=(M, 1)?

分類Dev

How to covert INT to VARCHAR in SQL condition

分類Dev

How to covert a character string into a list variable in R?

分類Dev

How to get the equilibrium index of an array in O(n)?

分類Dev

Converting an (n,m) shaped numpy array into an (n,m,1,1) shaped array

分類Dev

How can I create a numpy array with shape (0, 2)?

分類Dev

How to find all shapes in a Visio drawing and add each shape to an array?

分類Dev

How to prove (forall n m : nat, (n <? m) = false -> m <= n) in Coq?

分類Dev

Covert time duration format "%h%m%s" to seconds

分類Dev

How do I covert kebab-case into PascalCase?

分類Dev

How to generalize a multiplication table for (n * m)

分類Dev

How to update a numpy array based on a masked array w/ same dimension and shape

分類Dev

How to generated N numbers in array that sum of these numbers is equal to 0

分類Dev

How can I remove all but the last N elements from an array?

分類Dev

How can be array elements multiplied with big O(n)

分類Dev

How to delete items from an array that have an index that is a multiple of N

分類Dev

How to read an array up till the new line '\n'?

分類Dev

Divide array into N chunks

分類Dev

Resizing an array to another shape in Python

分類Dev

How to make a shape in swift

分類Dev

Back to Coq proof checker after 5-8 years away: how to prove that (forall n, m : N, (n - (S m)) = pred(n - m))?

分類Dev

How are arrays of type std::vector<std::array<T, N>> or std::array<std::vector<T>,N> stored in memory?

分類Dev

How do you access multi-dimension array by N array of index element-wise?

分類Dev

How to convert 1-d array into n-d array with considering NaN in elements?

分類Dev

How to covert PL/SQL .sql file to SQL*PLUS so it can be run with Windows Task Scheduler

分類Dev

Array(n)とArray(n).fillの違いは?

分類Dev

Array(n)と[... Array(n)]の違い

Related 関連記事

  1. 1

    How to index a numpy array of dimension N with a 1-dimensional array of shape (N,)

  2. 2

    Combining (m,m,n) arrays of the lists into an (m,m,n) array

  3. 3

    For a bigger-than-memory dask array of size=(M, N): How to re-chunk from chunks=(1, N) to chunks=(M, 1)?

  4. 4

    How to covert INT to VARCHAR in SQL condition

  5. 5

    How to covert a character string into a list variable in R?

  6. 6

    How to get the equilibrium index of an array in O(n)?

  7. 7

    Converting an (n,m) shaped numpy array into an (n,m,1,1) shaped array

  8. 8

    How can I create a numpy array with shape (0, 2)?

  9. 9

    How to find all shapes in a Visio drawing and add each shape to an array?

  10. 10

    How to prove (forall n m : nat, (n <? m) = false -> m <= n) in Coq?

  11. 11

    Covert time duration format "%h%m%s" to seconds

  12. 12

    How do I covert kebab-case into PascalCase?

  13. 13

    How to generalize a multiplication table for (n * m)

  14. 14

    How to update a numpy array based on a masked array w/ same dimension and shape

  15. 15

    How to generated N numbers in array that sum of these numbers is equal to 0

  16. 16

    How can I remove all but the last N elements from an array?

  17. 17

    How can be array elements multiplied with big O(n)

  18. 18

    How to delete items from an array that have an index that is a multiple of N

  19. 19

    How to read an array up till the new line '\n'?

  20. 20

    Divide array into N chunks

  21. 21

    Resizing an array to another shape in Python

  22. 22

    How to make a shape in swift

  23. 23

    Back to Coq proof checker after 5-8 years away: how to prove that (forall n, m : N, (n - (S m)) = pred(n - m))?

  24. 24

    How are arrays of type std::vector<std::array<T, N>> or std::array<std::vector<T>,N> stored in memory?

  25. 25

    How do you access multi-dimension array by N array of index element-wise?

  26. 26

    How to convert 1-d array into n-d array with considering NaN in elements?

  27. 27

    How to covert PL/SQL .sql file to SQL*PLUS so it can be run with Windows Task Scheduler

  28. 28

    Array(n)とArray(n).fillの違いは?

  29. 29

    Array(n)と[... Array(n)]の違い

ホットタグ

アーカイブ