7.5 Implementing Cluster Analysis: Earthquakes

We have real data describing 500 earthquakes that occurred during a month in late 2022. Given the raw data, it might be difficult to see any type of pattern or similarity in this data set. However, if we extend our cluster analysis technique from the previous section, we might discover some interesting results.

7.5.1 File Processing

Our first problem will be to find a way to process and store the data contained in the data file so that we can use it in our clustering algorithm. Recall that in the earthquakes.csv file, the first line contains column titles that identify each data item, like this:


Each succeeding line of the file describes one earthquake. The line for the first earthquake ...

Get Python Programming in Context, 4th Edition 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.