I am working with a process that outputs a list of lists like this:
data_recieved = [[], [1, 5]]
There will always be a list of lists but null values are not included when data does not exist. This causes the array to evaluate as 1 dimensional.
print(np.ndim(np.array(data_recieved)))
1
But if I impute the missing values, it resolves to 2d.
modified_data = [[np.nan, np.nan], [1, 5]]
print(np.ndim(np.array(modified_data)))
2
I could write something to loop through each item and figure out the maximum sublist length and then loop through again to add the null values but that seems sloppy and inefficient. Is there a clean way to force this input into a 2d array?