Data Frame Functions
An introduction to the most common and important data frame functions.
We'll cover the following...
Preview the data frame
You can now use the Pandas head()
command to preview the data frame in Jupyter Notebook. The head()
function must come after the variable name of the data frame, which is df.
df.head()
import pandas as pdimport seaborn as snsdf = pd.read_csv('listings.csv')print(df.head())
Notice that the first row (id 2015, located in Mitte) is indexed at position 0 of the data frame. The fifth row, meanwhile, is indexed at position 4. This is because the indexing of elements in Python starts at 0, which means you will need to subtract 1 from the actual number of rows when calling a specific row from the data frame.
The data frame’s columns, while not labeled numerically, follow the same logic. The first column (id
) is indexed at 0, and the fifth column (neighbourhood_group
) is indexed at 4. This is a fixed feature of working in Python which must be kept in mind when calling specific rows or columns. By default, head()
displays the first five rows of the data frame. Still, you can increase the number of rows by specifying n
number of rows inside the parentheses; you can get such results from the app below.
import pandas as pdimport seaborn as snsdf = pd.read_csv('listings.csv')print(df.head(10))
The argument ...