1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| >>> import numpy >>> demolist1 [[1, 2, 3], [4, 5, 6], [7, 8, 9]] >>> demolist2 [[[1, 2], 3], [[4, 5], 6], [[7, 8], 9]]
>>> list(numpy.concatenate(demolist1)) [1, 2, 3, 4, 5, 6, 7, 8, 9] >>> list(numpy.concatenate(demolist2)) :6: 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 [[1, 2], 3, [4, 5], 6, [7, 8], 9]
>>> list(numpy.array(demolist1).flat) [1, 2, 3, 4, 5, 6, 7, 8, 9] >>> list(numpy.array(demolist2).flat) __main__: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 [[1, 2], 3, [4, 5], 6, [7, 8], 9]
|