Recipe: How to Flatten a Matrix?
DATA MUNGING PYTHON MATRIX DATA CLEANING PYTHON

How to Flatten a Matrix?

This recipe helps you Flatten a Matrix
In [1]:
## How to Flatten a Matrix
def Kickstarter_Example_10():
    print()
    print(format('How to Flatten a Matrix', '*^72'))

    #load library
    import numpy as np

    # Create matrix
    matrixA = np.array([[1, 2, 3, 23],
                       [4, 5, 6, 25],
                       [7, 8, 9, 28],
                       [10, 11, 12, 41]])

    matrixB = np.array([[2, 3, 4],
                       [5, 6, 9],
                       [7, 8, 1]])

    # Return a flatten matrix
    print(); print(matrixA.flatten())
    print(); print(matrixB.flatten())
Kickstarter_Example_10()
************************How to Flatten a Matrix*************************

[ 1  2  3 23  4  5  6 25  7  8  9 28 10 11 12 41]

[2 3 4 5 6 9 7 8 1]


Stuck at work?
Can't find the recipe you are looking for. Let us know and we will find an expert to create the recipe for you. Click here
Companies using this Recipe
1 developer from HvH
1 developer from MudraCircle
1 developer from Altimetrik
1 developer from IQVIA
1 developer from Vodafone
1 developer from ANAC
1 developer from KPMG
1 developer from YASH Technologies
1 developer from eClerx
1 developer from LTI