47993/slice-an-array-into-multiple-arrays-python
I have an array that I would like to slice into multiple arrays in the form of:
M = [1,2,3 4,5,6 7,8,9]
to [ [1],[2]....[9] ] (List of arrays)
can use numpy.reshape.
In your case, pass 1 as 2nd dimension, and let the method infer the first dimension by passing -1:
M = [1, 2, 3, 4, 5, 6, 7, 8, 9] np.reshape(M, (-1, 1))
Slicing is basically extracting particular set of ...READ MORE
Hi@akhtar, You need to import the NumPy module ...READ MORE
my_list = [1,2,3,4,5,6,7] len(my_list) # 7 The same works for ...READ MORE
The datetime class has a method strftime. strftime() ...READ MORE
You can also use the random library's ...READ MORE
Syntax : list. count(value) Code: colors = ['red', 'green', ...READ MORE
Enumerate() method adds a counter to an ...READ MORE
You can simply the built-in function in ...READ MORE
Python doesn't have a native array data ...READ MORE
You don't have a template matching tabularQueryResult in your ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.