Solution 7.1
Please use the following steps to complete the activity:
- Open a Jupyter notebook.
- 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/Chapter07/Data/student-mat.csv' data_frame = pd.read_csv(file_url, delimiter=';')
Note that CSV uses ;
as a delimiter. So, we have used the delimiter
option with pd.read_csv()
to explicitly specify the correct delimiter to be used in order to read the dataset.
- Modify the DataFrame to contain only these columns:
school
,sex
,age
,address
,health
,absences
,G1
,G2
, andG3
:data_frame = data_frame[[ Â Â Â Â 'school', 'sex', 'age', 'address', 'health', 'absences', 'G1', 'G2', 'G3' ]]
- Display the first 10 rows of the DataFrame:
data_frame.head(10)
The output will...