import numpy as np x = np.array([8,5,3,1,77,1]) y = np.array([6,71,56,11,23]) print(x)print(y) z=np.concatenate([x,y]) print()print(‘Concatenated array: ‘,z) Output [ 8 5 3 1 77 1][ 6 71 56 11 23] Concatenated array: [ 8 5 3 1 77 1 6 71 56 11 23]
Author Archives: Python programming examples for beginners
Numpy reduce function
Numpy reduce function
Matrix aggregate functions
from numpy import * x = matrix([[11,22,33],[44,55,66],[1,2,3]]) print(‘Matrix: \n’,x) print() print(‘Largest Element: ‘,x.max()) print() print(‘Smallest Element: ‘,x.min()) print() print(‘Sum: ‘,x.sum()) print() print(‘Mean: ‘,x.mean()) Output Matrix: [[11 22 33][44 55 66][ 1 2 3]] Largest Element: 66 Smallest Element: 1 Sum: 237 Mean: 26.333333333333332
Matrix diagonal
Matrix diagonal elements
Matrix transpose
from numpy import * x = matrix([[11,22,33],[44,55,66],[1,2,3]]) print(‘Matrix before transpose:\n’,x) print() print(‘Matrix after transpose:\n’,x.transpose()) Output Matrix before transpose:[[11 22 33][44 55 66][ 1 2 3]] Matrix after transpose:[[11 44 1][22 55 2][33 66 3]]
Matrix arithmetic operations
from numpy import * x = matrix([[11,22,33],[44,55,66],[1,2,3]]) y = matrix([[10,20,30],[40,50,51],[4,5,6]]) print(‘Matrix x:\n’,x)print(‘Matrix y:\n’,y) print() print(‘Addition: \n’,x + y) print() print(‘Subtraction: \n’,x – y) print() print(‘Multiplication: \n’,x * y) print() print(‘Division: \n’,x / y) Output Matrix x:[[11 22 33][44 55 66][ 1 2 3]]Matrix y:[[10 20 30][40 50 51][ 4 5 6]] Addition: [[ 21 42Continue reading “Matrix arithmetic operations”
Numpy array attributes and functions
Numpy reshape, flatten
Function returns multiple functions
function returns multiple functions
Numpy array
Numpy array
MySQL select with where
select with where