Analyzing DataFrames - PANDAS (Analyzing DataFrames) Flashcards
One of the most used method for getting a quick overview of the DataFrame, is the head() method.
Viewing the Data
The head() method returns the headers and a specified number of rows, starting from the top.
Viewing the Data
if the number of rows is not specified, the head() method will return the top 5 rows.
print(df.head())
There is also a tail() method for viewing the last rows of the DataFrame.
print(df.tail())
The tail() method returns the headers and a specified number of rows, starting from the bottom.
print(df.tail())
The DataFrames object has a method called info(), that gives you more information about the data set.
print(df.info())
The info() method also tells us how many Non-Null values there are present in each column
Null Values
Empty values, or Null values, can be bad when analyzing data, and you should consider removing rows with empty values.
Null Values
Exercise - What is a correct syntax for printing the first 10 rows of a DataFrame?
print(df.head(10))
Exercise - What is a correct syntax for printing the last 10 rows of a DataFrame?
print(df.tail(10))
Exercise - True or False. If number of rows is not specified, the tail() method will return all rows.
False