NumPy Splitting Array

Machine Learning courses with 100+ Real-time projects Start Now!!

Program 1

import numpy as np
#split() ,array_split(),hsplit(),vsplit()

ar1=np.array([[1,2,3],[4,5,6],[7,8,9],[10,11,12]])
newar=np.vsplit(ar1,2)
print(ar1)
print("----------------------------------------")
print(newar)
















# hsplit()
# ar1=np.array([[1,2,3],[4,5,6],[7,8,9],[10,11,12]])
# print(ar1)
# print("--------------------------------------------------")
# newar=np.hsplit(ar1,3)
# print(newar)















# ar1=np.array([[1,2,3],[4,5,6],[7,8,9],[10,11,12]])
# print(ar1)
# print(ar1.shape)
# print("--------------------------------------------------")
# ar2=print(np.array_split(ar1,2,axis=0))  # ar2 is ab object of list  0-Row 1 -Col
# ar2=np.array(ar2)
# print(ar2)




#print(ar2.shape)
# ar=np.array([10,20,30,40,50,60])
# print(ar)
# print(ar.shape)
# print("-----------------------------")
# #newar=np.split(ar,4)
# newar=np.array_split(ar,4)
# print(newar)
# newar=np.array(newar)

# #print(newar.shape)

 

You give me 15 seconds I promise you best tutorials
Please share your happy experience on Google

courses
Image

DataFlair Team

DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.

Leave a Reply

Your email address will not be published. Required fields are marked *