numpy.rot90(array, k=number_rotations, axes=(0, 1))
In [x]: theta = np.radians(30)
In [x]: c, s = np.cos(theta), np.sin(theta)
In [x]: R = np.array(((c, -s), (s, c)))
Out[x]: print(R)
[[ 0.8660254 -0.5 ]
[ 0.5 0.8660254]]
def rotate(matrix):
rows = len(matrix)
cols = len(matrix[0])
res = []
for i in range(cols):
temp = []
for j in range(rows):
temp.append(matrix[j][i])
res.append(temp[::-1])
return res
matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
print(rotate(matrix))