Introduction
This article will describe how to get the size of dataframe using Pandas library in Jupyter Notebook. Actually, this is an article that has a relation with another article with the title of ‘How to Read CSV File into a DataFrame using Pandas Library in Jupyter Notebook’. The article exist in this link for further reference. So, the scenario is retrieving data from CSV file into a DataFrame using Pandas library. The execution of the process is in Jupyter Notebook. The following is the execution of the Jupyter Notebook :
(myenv) C:\python\data-science>jupyter notebook [I 17:08:28.062 NotebookApp] Serving notebooks from local directory: C:\python\data-science [I 17:08:28.062 NotebookApp] The Jupyter Notebook is running at: [I 17:08:28.067 NotebookApp] http://localhost:8888/?token=4dd9801ef2aacad1d445955b0ae4621b4c669da84c617e7b [I 17:08:28.068 NotebookApp] or http://127.0.0.1:8888/?token=4dd9801ef2aacad1d445955b0ae4621b4c669da84c617e7b [I 17:08:28.070 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation). [C 17:08:28.225 NotebookApp] To access the notebook, open this file in a browser: file:///C:/Users/Personal/AppData/Roaming/jupyter/runtime/nbserver-8796-open.html Or copy and paste one of these URLs: http://localhost:8888/?token=4dd9801ef2aacad1d445955b0ae4621b4c669da84c617e7b or http://127.0.0.1:8888/?token=4dd9801ef2aacad1d445955b0ae4621b4c669da84c617e7b
Get the Size of DataFrame using Pandas Library in Jupyter Notebook
After executing the Jupyter Notebook, just execute to read the CSV file as in the following script :
import pandas as pd data = pd.read_csv("transactions1.csv",sep=";",low_memory=False)
In order to get the dimension of the DataFrame, just execute the following command in the Jupyter Notebook :
data.size
After executing the above command, the output will appear as in the following images :
The size is correct. Referring to the above output listing all the data available in the DataFrame, it consists of 641914 rows x 30 columns which is producing the size of 19257420. So, DataFrame size is actually representing the size of the rows and columns of the DataFrame itself. Just look at the article in this link to see about the row size of DataFrame and also this link to refer on the column size of a Dataframe as an additional reference.
One thought on “How to Get the Size of DataFrame using Pandas Library in Jupyter Notebook”