From the course: pandas Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Using shape - pandas Tutorial
From the course: pandas Essential Training
Using shape
- [Instructor] Shape. The shape attribute returns a tuple, that's rows and columns representing the dimensionality of the DataFrame. It's a good idea to check this against the original CSV file to ensure that all the expected data has been read into the DataFrame. The shape attribute is useful for confirming the dimensions of your dataset. We'll head over to our Jupyter Notebook. What we need to enter here is our DataFrame which is 00 and shape, the shape attribute. So, the 29,216 corresponds to the number of rows in the CSV file and the 10 corresponds to the number of columns. We can confirm that and we can see for example here that the city, edition, sport and so on, these are the 10 columns that we have and we actually have 29,216 rows of data in our table. One helpful tip is that sometimes you might only want the number of rows or columns as part of your code and you can extract this information from this tuple by just typing shape and zero for the number of rows and if you just…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.