Manage an Incorrect ColumnManage an Incorrect Column

So, you received the result object. This means that the type of the column is non-numerical, but to calculate necessary values, the column need to be numerical. Let's change that.

  1. Firstly, we need to replace - with .. To do so, you will apply the function .str.replace() to replace the character in the string in the dataset column. The syntax is
    In our case, old_symbol is -, and . is the new_symbol.
  2. Then, convert the column to the float data type. To do so, use .astype() function. The syntax is data['column_name'].astype('type').
    In our case, the type is 'float'.


Your task is to:

  1. Follow the algorithm above and firstly replace - with . in the column 'Fare'.
  2. Convert the column 'Fare' to the 'float' data type.
  3. Output the type of the column 'Fare'.

Everything was clear?

Section 5. Chapter 8
toggle bottom row