Recipe: How to Create a Vector or Matrix in Python?
DATA MUNGING PYTHON MATRIX DATA CLEANING PYTHON

How to Create a Vector or Matrix in Python?

This recipe helps you Create a Vector or Matrix in Python
In [1]:
## How to Create & Transpose a Vector or Matrix
def Kickstarter_Example_1():
    print()
    print(format('How to Create/Transpose a Vector and/or Matrix', '*^75'))

    # Load library
    import numpy as np

    # Create vector
    vector = np.array([1, 2, 3, 4, 5, 6])
    print()
    print("Original Vector: \n", vector)
    # Tranpose vector
    V = vector.T
    print("Transpose Vector: \n", V)

    # Create matrix
    matrix = np.array([[1, 2, 3],
                   [4, 5, 6],
                   [7, 8, 9]])
    print()
    print("Original Matrix: \n", matrix)
    # Transpose matrix
    M = matrix.T
    print("Transpose Matrix: \n", M)

Kickstarter_Example_1()
**************How to Create/Transpose a Vector and/or Matrix***************

Original Vector:
 [1 2 3 4 5 6]
Transpose Vector:
 [1 2 3 4 5 6]

Original Matrix:
 [[1 2 3]
 [4 5 6]
 [7 8 9]]
Transpose Matrix:
 [[1 4 7]
 [2 5 8]
 [3 6 9]]


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 Microsoft
1 developer from Sony
1 developer from YASH Technologies
1 developer from Altimetrik
1 developer from Infiniti Research
1 developer from MudraCircle
1 developer from Tech Mahindra
1 developer from ANAC
1 developer from KPMG