Solution 4.1
Perform the following steps to complete the activity:
- Open a new Jupyter notebook and select the
Pandas_Workshop
kernel. - Import the
pandas
package:import pandas as pd
- Load the CSV file as a DataFrame:
file_url = 'https://raw.githubusercontent.com/PacktWorkshops/The-Pandas-Workshop/master/Chapter04/Data/car.csv' data_frame = pd.read_csv(file_url)
- Display the first
10
rows of the DataFrame:data_frame.head(10)
The output will be as follows:
Figure 15.10 – Displaying the top 10 rows of the DataFrame
You can see some missing data (NaN
) in a couple of columns. Displaying the DataFrame details with the info()
function should help us to confirm this.
- Display the data types of each column in the DataFrame using the
info()
method:data_frame.info()
The output will be as follows:
Figure 15.11 – Displaying the full details of the DataFrame
As suspected, most columns have...