DATA MUNGING
PYTHON MATRIX
DATA CLEANING PYTHON

In [1]:

```
## How to calculate Diagonal of a Matrix
def Kickstarter_Example_8():
print()
print(format('How to calculate Diagonal of a Matrix', '*^72'))
# Load library
import numpy as np
# Create matrix
matrix = np.array([[1, 2, 3, 23],
[4, 5, 6, 25],
[7, 8, 9, 28],
[10, 11, 12, 41]])
# Return diagonal elements
print()
print(matrix.diagonal())
# Calculate the tracre of the matrix
print()
print(matrix.diagonal().sum())
Kickstarter_Example_8()
```

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
KPMG

1
developer from
Vodafone

1
developer from
Altimetrik

1
developer from
LTI

1
developer from
YASH Technologies

1
developer from
ANAC

1
developer from
MudraCircle

1
developer from
HvH

1
developer from
New Delhi DataPoint