Numpy size() function | Python Last Updated : 12 Jul, 2025 Comments Improve Suggest changes Like Article Like Report numpy.size() function in Python is used to count the number of elements in a NumPy array. You can use it to get the total count of all elements, or to count elements along a specific axis, such as rows or columns in a multidimensional array. This makes it useful when quickly trying to understand the shape or structure of the given data.Syntax:numpy.size(arr, axis=None)Where: arr is input data in the form of an array.axis represent along which the elements (rows or columns) are counted. The function returns an integer as an output representing the number of elements. Example Usages of numpy.size() Function1. To Find Total Number of ElementsHere we create a 2D array arr with 2 rows and 4 columns and use np.size() function which will return the total number of elements in the array. Python import numpy as np arr = np.array([[1, 2, 3, 4], [5, 6, 7, 8]]) print(np.size(arr)) Output:82. To Count the Elements Along a Specific AxisHere 0 is used to denote the axis as rows and 1 is used to denote axis as columns. Therefore np.size(arr, 0) will returns the number of rows and np.size(arr, 1) returns the number of columns. Python import numpy as np arr = np.array([[1, 2, 3, 4], [5, 6, 7, 8]]) print(np.size(arr, 0)) print(np.size(arr, 1)) Output:243. To Count Elements in a 3D ArrayIn this case we are working with a 3D array having the shape (2, 2, 2). Here:axis=0 refers to the number of blocks (first level of depth).axis=1 refers to the number of rows in each block.axis=2 refers to the number of columns in each row. Python import numpy as np arr = np.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]]) print(np.size(arr)) print(np.size(arr, 0)) print(np.size(arr, 1)) print(np.size(arr, 2)) Output:8222The numpy.size() function is a tool to understand how many elements exist in your array whether it's one-dimensional or multi-dimensional. It's helpful when you're working with large datasets and want to inspect structure or dimensions. Comment More infoAdvertise with us Next Article Company Preparation S sanjoy_62 Follow Improve Article Tags : Python Python-numpy Practice Tags : python Similar Reads Interview PreparationInterview Preparation For Software DevelopersMust Coding Questions - Company-wise Must Do Coding Questions - Topic-wiseCompany-wise Practice ProblemsCompany PreparationCompetitive ProgrammingSoftware Design-PatternsCompany-wise Interview ExperienceExperienced - Interview ExperiencesInternship - Interview ExperiencesPractice @GeeksforgeeksProblem of the DayTopic-wise PracticeDifficulty Level - SchoolDifficulty Level - BasicDifficulty Level - EasyDifficulty Level - MediumDifficulty Level - HardLeaderboard !!Explore More...Data StructuresArraysLinked ListStackQueueBinary TreeBinary Search TreeHeapHashingGraphAdvance Data StructuresMatrixStringAll Data StructuresAlgorithmsAnalysis of AlgorithmsSearching AlgorithmsSorting AlgorithmsPattern SearchingGeometric AlgorithmsMathematical AlgorithmsRandomized AlgorithmsGreedy AlgorithmsDynamic ProgrammingDivide & ConquerBacktrackingBranch & BoundAll AlgorithmsProgramming LanguagesCC++JavaPythonC#Go LangSQLPHPScalaPerlKotlinWeb TechnologiesHTMLCSSJavaScriptBootstrapTailwind CSSAngularJSReactJSjQueryNodeJSPHPWeb DesignWeb BrowserFile FormatsComputer Science SubjectsOperating SystemsDBMSComputer NetworkComputer Organization & ArchitectureTOCCompiler DesignDigital Elec. & Logic DesignSoftware EngineeringEngineering MathematicsData Science & MLComplete Data Science CourseData Science TutorialMachine Learning TutorialDeep Learning TutorialNLP TutorialMachine Learning ProjectsData Analysis TutorialTutorial LibraryPython TutorialDjango TutorialPandas TutorialKivy TutorialTkinter TutorialOpenCV TutorialSelenium TutorialGATE CSGATE CS NotesGate CornerPrevious Year GATE PapersLast Minute Notes (LMNs)Important Topic For GATE CSGATE CoursePrevious Year Paper: CS exams Like