Dataframes
Dataframes are the basis of Pandas. Dataframes are like Excel Sheets, effectively. They’re tables that contain information formatted as rows and columns. Click the next cell, and press Shift+Enter, and run it. This cell first creates a dictionary and then converts it to a dataframe. The table that has appeared below the cell is what a dataframe looks like.
Head
There are many operations on Dataframes, but there are only a few we’ll be using.
.head()
is one of the most useful dataframe methods. This operation produces the top or head of a dataframe. The operation gives the first 5 rows by default, but you can specify any number n of rows as .head(n)
Run the next two cells. These will give the top of a data frame. We use
.head()
to get a sense of what the dataframe is like, before we work on it.We’ll cover more Dataframe operations soon, but we’ll do it as part of the ML we do. For now, however, let’s review Python first.
Copyright © 2021 Code 4 Tomorrow. All rights reserved.
The code in this course is licensed under the MIT License.
If you would like to use content from any of our courses, you must obtain our explicit written permission and provide credit. Please contact classes@code4tomorrow.org for inquiries.