Extracting the title from the name

If you look closely at the passenger names, you will notice that they are all in the {family name}{title}{first names} format. It would be interesting to extract the title as a new variable. The following query uses the split function, which returns an array. We need the second element of that array:

SELECT name, split(name, ' ')[2] as title from titanic;

Get Effective Amazon Machine Learning now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.