From book 'Python for data analysis'