Applied Data Science Coding in Python: How to get dimension of Dataset

How to get dimension of Dataset

When working with datasets in Python, it’s important to know the dimension of your dataset, which refers to the number of rows and columns in your data. Knowing the dimension of your dataset can help you better understand the data and make better decisions when working with it.

There are two main ways to get the dimension of a dataset in Python:

Using the shape attribute: If you have loaded your dataset into a Pandas DataFrame or a Numpy array, you can use the shape attribute to get the dimension of the dataset. This attribute returns a tuple where the first element is the number of rows and the second element is the number of columns.

Using the len() function: You can also use the len() function to get the number of rows in your dataset. You can use len() function on DataFrame or array to get the number of rows.

In summary, you can use the shape attribute or len() function to get the dimension of a dataset in Python. The shape attribute returns a tuple with the number of rows and columns in the dataset, while the len() function returns the number of rows. Knowing the dimension of your dataset can help you better understand the data and make better decisions when working with it.

 

In this Applied Machine Learning & Data Science Recipe, the reader will learn: How to get dimension of Dataset.



 

Essential Gigs