import numpy as np a1 = [[1,2,3],[4,5,6]] arr = np.array(a1) if arr.ndim == 0: print(arr) elif arr.ndim == 1: row = 1 col = arr.size for i in range(row): for j in range(col): print(arr[i][j], end = " ") print() else: size = arr.shape row = size[0] col = size[1] for i in range(row): for j in range(col): print(arr[i][j], end = " ") print()
ndim() can be used to find the dimension 1D - list inside a function 2D - list of the list inside a function 3D- list of list of list inside a function, with the addition of each list, comes an extra square bracket
Sir.. Me video purthiga chudakapoyina.. Me manual efforts ki like vesthunna and subscriber ayeppoya sir..chaala neat ga ,baaga chepthunaru
GOOD
@@kasi3304 Very Good
👍🏻
thank you sir,
what about geomspace please tell us about geomspace
How to know 1 d or 2d
by using np.ndim
import numpy as np
a1 = [[1,2,3],[4,5,6]]
arr = np.array(a1)
if arr.ndim == 0:
print(arr)
elif arr.ndim == 1:
row = 1
col = arr.size
for i in range(row):
for j in range(col):
print(arr[i][j], end = " ")
print()
else:
size = arr.shape
row = size[0]
col = size[1]
for i in range(row):
for j in range(col):
print(arr[i][j], end = " ")
print()
Sir still we are not clarity on dimensions
ndim() can be used to find the dimension
1D - list inside a function
2D - list of the list inside a function
3D- list of list of list inside a function,
with the addition of each list, comes an extra square bracket