Pandas df.size, df.shape and df.ndim Methods Last Updated : 26 Apr, 2025 Comments Improve Suggest changes Like Article Like Report Understanding structure of our data is an important step in data analysis and Pandas helps in making this easy with its df.size, df.shape and df.ndim functions. They allow us to identify the size, shape and dimensions of our DataFrame. In this article, we will see how to implement these functions in python.We can use any dataset for its understanding but here we are using NBA dataset which contains data from NBA players. You can download it from here.1. Pandas Size Function(df.size)df.size is used to return the total number of elements in a DataFrame or Series. If we're working with a DataFrame it gives the product of rows and columns or if we're working with a Series it just returns the number of elements (rows).Syntax: dataframe.sizeReturn : Size of dataframe/series.Here we use pandas library read nba.csv and prints the total number of elements (size) in the DataFrame. Python import pandas as pd data = pd.read_csv("/content/nba.csv") size = data.size print("Size = {}".format(size)) Output:Size = 41222. Pandas Shape Function(df.shape)The df.shape function returns a tuple representing dimensions of the DataFrame. It provides the number of rows (records) and columns (attributes) in the DataFrame.Syntax: dataframe.shapeReturn : A tuple in the form of (rows, columns).Here we use pandas library to read and then it prints the shape of the DataFrame which includes the number of rows and columns. Python import pandas as pd data = pd.read_csv("/content/nba.csv") shape = data.shape print("Shape = {}".format(shape)) Output:Shape = (458, 9)3. Pandas ndim Function(df.ndim)The df.ndim function returns number of dimensions (or axes) in the DataFrame or Series. A DataFrame is always two-dimensional (rows and columns) so it returns 2. A Series is one-dimensional so it returns 1.Syntax: dataframe.ndimReturn:1 for a Series (one-dimensional).2 for a DataFrame (two-dimensional).Here we use pandas library to read and then it prints number of dimensions (ndim) for both the DataFrame and a specific column ("Salary") treated as a Series within the DataFrame. Python import pandas as pd data = pd.read_csv("/content/nba.csv") df_ndim = data.ndim series_ndim = data["Salary"].ndim print("ndim of dataframe = {}\nndim of series ={}". format(df_ndim, series_ndim)) Output:ndim of dataframe = 2ndim of series =1These methods help us to quickly understand the structure of our data and helps in providing more efficient and effective data analysis with Pandas. Comment More infoAdvertise with us Next Article Pandas DataFrame describe() Method K Kartikaybhutani Follow Improve Article Tags : Misc Python Python-pandas Python pandas-dataFrame Pandas-DataFrame-Methods +1 More Practice Tags : Miscpython Similar Reads Pandas Functions in Python: A Toolkit for Data Analysis Pandas is one of the most used libraries in Python for data science or data analysis. It can read data from CSV or Excel files, manipulate the data, and generate insights from it. Pandas can also be used to clean data, filter data, and visualize data. Whether you are a beginner or an experienced pro 6 min read Pandas Read CSV in Python CSV files are the Comma Separated Files. It allows users to load tabular data into a DataFrame, which is a powerful structure for data manipulation and analysis. To access data from the CSV file, we require a function read_csv() from Pandas that retrieves data in the form of the data frame. Hereâs a 6 min read Python | Pandas Dataframe/Series.head() method Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric Python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas head() method is used to return top n (5 by default) rows of a data frame or se 2 min read Pandas Dataframe/Series.tail() method - Python Python is a popular language for data analysis because it has many useful libraries. One of these libraries is Pandas, which makes working with data easier.The .tail() method in Pandas helps us see the last n rows of a DataFrame or Series. This is useful when dealing with large datasets and we need 2 min read Pandas Dataframe.sample() | Python Pandas DataFrame.sample() function is used to select randomly rows or columns from a DataFrame. It proves particularly helpful while dealing with huge datasets where we want to test or analyze a small representative subset. We can define the number or proportion of items to sample and manage randomn 2 min read Python | Pandas dataframe.info() When working with data in Python understanding the structure and content of our dataset is important. The dataframe.info() method in Pandas helps us in providing a concise summary of our DataFrame and it quickly assesses its structure, identify issues like missing values and optimize memory usage.Ke 2 min read Pandas DataFrame dtypes Property | Find DataType of Columns Pandas DataFrame is a two-dimensional size-mutable, potentially heterogeneous tabular data structure with labeled axes (rows and columns). Pandas DataFrame.dtypes attribute returns a series with the data type of each column.Example:Pythonimport pandas as pd df = pd.DataFrame({'Weight': [45, 88, 56, 3 min read Pandas df.size, df.shape and df.ndim Methods Understanding structure of our data is an important step in data analysis and Pandas helps in making this easy with its df.size, df.shape and df.ndim functions. They allow us to identify the size, shape and dimensions of our DataFrame. In this article, we will see how to implement these functions in 2 min read Pandas DataFrame describe() Method describe() method in Pandas is used to generate descriptive statistics of DataFrame columns. It gives a quick summary of key statistical metrics like mean, standard deviation, percentiles, and more. By default, describe() works with numeric data but can also handle categorical data, offering tailore 3 min read Python | Pandas Series.unique() Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric Python packages. Pandas is one of those packages, and makes importing and analyzing data much easier. While analyzing the data, many times the user wants to see the unique values in a par 1 min read Like