Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

How to solve duplicated lists in numpy 1.24?

$
0
0

Now I have a 2-dimensional list which have many duplicated lists in it:

sta_list = [[31, 30, 11, 3, 1, 0], [31, 30, 11, 3, 1, 0], [31, 30, 11, 3, 1, 0], ……, [31, 30, 11, 3, 1, 0], [31, 30, 11, 3, 1, 0], [34, 33, 1, 0], ……]

In numpy 1.22, I can use np.unique to remove duplicated lists like this:

np.unique(np.array(sta_lists))

But in numpy 1.24, it can only get this error:

Traceback (most recent call last):  File "C:\Users\yy\AppData\Roaming\JetBrains\IntelliJIdea2023.3\plugins\python\helpers-pro\pydevd_asyncio\pydevd_asyncio_utils.py", line 114, in _exec_async_code    result = func()             ^^^^^^  File "<input>", line 1, in <module>ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (396,) + inhomogeneous part.

So how to solve the problem in python 3.11 and numpy 1.24 rather than retreating to older python and numpy?


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>