NumPy Copy Vs View | LearnHindiTuts
Có thể bạn quan tâm
If tutorials available on this website are helpful for you, please whitelist this website in your ad blocker😭 or Donate to help us ❤️ pay for the web hosting to keep the website running.
NumPy module में ndarray Object का copy() और view() दोनों methods का use array data को copy करने के लिए किया जाता है। लेकिन इन दोनों methods में एक major difference है।
NumPy difference between view() and copy()
copy() method का use करके copy किये गए data में अगर कोई changes होता है , तो original data पर कोई effect नहीं पड़ता है। means वो copied data original data से independent होता है।
NumPy copy() Example
Copy Fullscreen Close Fullscreen Run #import numpy module. import numpy as np org_arr = np.array([10, 20, 30, 40, 50]) #now copy data and made some changes. copy_arr = org_arr.copy() copy_arr[0] = 60 print('Original Data : ', org_arr) print('Copied Data : ', copy_arr)Output
C:\Users\Rahulkumar\Desktop\python>python module_numpy.py Original Data : [10 20 30 40 50] Copied Data : [60 20 30 40 50]Example में आप clearly देख सकते हैं , कि copied data में changes करने पर original data में कोई changes नहीं हुए हैं।
NumPy view() Example
जबकि view() method का use करके copy किये गए data में अगर कोई changes होता है , तो same changes original में भी होते हैं । या पूरी तरह से original data पर ही dependent होता है।See Example :
Copy Fullscreen Close Fullscreen Run import numpy as np org_arr = np.array([10, 20, 30, 40, 50]) #now copy data and made some changes using view() mwthod. copy_arr = org_arr.view() copy_arr[0] = 60 print('Original Data : ', org_arr) print('Copied Data : ', copy_arr))Output
C:\Users\Rahulkumar\Desktop\python>python module_numpy.py Original Data : [60 20 30 40 50] Copied Data : [60 20 30 40 50]Now you can see , view() method का use करके copy किये गए data में changes करने पर original data में भी changes हुए हैं।
Từ khóa » Np.copy Vs =
-
NumPy Array Copy Vs View - W3Schools
-
Why Do I Need ray() Or py()? - Stack Overflow
-
py — NumPy V1.23 Manual
-
Copies And Views — NumPy V1.23 Manual
-
Numpy Views Vs Copies: Avoiding Costly Mistakes - Jessica Yung
-
Copy And View In NumPy Array - GeeksforGeeks
-
Copy Vs View In NumPy - Morioh
-
NumPy Copies And Views - Copy Vs View In NumPy - DataFlair
-
NumPy - Copies & Views - Tutorialspoint
-
Python py() Vs NumPy py() - Source Code For The
-
Difference Between py() Vs py(array)
-
View Vs Copy In Numpy - YouTube
-
Numpy Array Copy Vs View - Numpy For Machine Learning 4
-
NumPy Deep Copy - Delft Stack