When I am reshaping the array ar as :ar.reshape(4,2) ,I am getting an array of 4 rows and 2 columns .However, when I am finding shape of ar using: ar.shape , output is coming (2,4). Why is (4,2) not shown even after reshaping the array?
In [11]: arOut[11]: array([1, 2, 3, 4, 5, 6, 7, 8])In [12]: ar.shape(2,4)---------------------------------------------------------------------------TypeError Traceback (most recent call last)<ipython-input-12-ac49df2b586f> in <module>----> 1 ar.shape(2,4)TypeError: 'tuple' object is not callable
It is said that shape is a method.But as far as my knowledge goes, it is an attribute of ndarray.Plz look into it.
--------------------------------------------------------In [68]: print(ar)[1 2 3 4 5 6 7 8]In [69]: ar.shape()---------------------------------------------------------------------------TypeError Traceback (most recent call last)<ipython-input-69-895c9f3eff17> in <module>----> 1 ar.shape()TypeError: 'tuple' object is not callable
Mam why do we have to use 2 brackets in the zeros method for giving only 1 set of values to it? I have tried it with one braces(opening and closing) then it is giving error. My OS used : Windows 10 ==>TypeError Traceback (most recent call last)<ipython-input-3-4b18b0e09899> in <module>----> 1 b=np.zeros(2,2)TypeError: data type not understood
Regrding the Arrays... While importing the numpy as np command did not execute. What could be the possible reasons for the same ?
Dear Sir/Madam,Such like of numpy library, how many library should we use for general programming?
Sir/madam,What is exactly the use of zero method? it let us create arrays only with zero elements? Where we use such arrays?
Sir/Madam,I am not clear with the explanation given in video about dtype? Is it come only in output just as a message or can do we also use in any input commands also?
21618 visits
Outline:Overview of array Usage of numpy library How to create arrays How to create two dimensional array arange() method reshape() method How to find the shape of an array? Create a new array with elements of different datatypes Identity matrix Zeros method
Overview of array Usage of numpy library How to create arrays How to create two dimensional array arange() method reshape() method How to find the shape of an array? Create a new array with elements of different datatypes Identity matrix Zeros method
Show video info
Pre-requisite