Python Forum
[solved] list of list with one or more empty one
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[solved] list of list with one or more empty one
#1
Hi

Without using a loop, is there a way to find an empty list as showing in the following example?

The idea is to find the location and to replace it by a value (such as -1 or zero for example) prior to chnage it to an array

import numpy as np

M = [[1], [], [5]]
Mprime = np.asarray(M, dtype=np.uint32)
logical error:
Error:
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (3,) + inhomogeneous part.
Thanks for your suggestion

Paul
Reply


Messages In This Thread
[solved] list of list with one or more empty one - by paul18fr - May-23-2023, 05:39 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question [Solved] How to refer to dataframe column name based on a list lorensa74 1 2,429 May-17-2021, 07:02 AM
Last Post: lorensa74
  convert a list of string+bytes into a list of strings (python 3) pacscaloupsu 4 11,102 Mar-17-2020, 07:21 AM
Last Post: markfilan
  search for a part of strinf from list in another list ! evilcode1 3 3,328 Oct-29-2018, 12:07 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020