Session Ready
Exercise

Customizing your spreadsheet import

Here you'll parse your spreadsheets and use additional arguments to skip rows, rename columns and select only particular columns.

The spreadsheet 'battledeath.xlsx' is already loaded as xl.

As before, you'll use the method parse(). This time, however, you'll add the additional arguments skiprows, names and parse_cols. These skip rows, name the columns and designate which columns to parse, respectively. All these arguments can be assigned to lists containing the specific row numbers, strings and column numbers, respectively.

Instructions
100 XP
  • Parse the first sheet by index. In doing so, skip the first row of data, then name the columns 'Country' and 'AAM due to War (2002)' by using the argument names. The arguments passed to skiprows and names will all need to be of type list.
  • Parse the second sheet by index. In doing so, parse only the first column with the parse_cols parameter, skip the first row and rename the column 'Country'. The argument passed to parse_cols will need to be of type list.