TL;DR Summary:
Manual Sorting Breaks Down: Grouping thousands of keywords by hand is slow and doesn’t scale, especially when similar phrases do not share the same words.Python Clustering Method: The script turns keywords into TF-IDF vectors and uses HDBSCAN to group them by meaning, while leaving outliers marked as noise instead of forcing a bad fit.Faster Topic Planning: Export keywords from BigQuery, run the notebook in Google Colab, and review the resulting clusters to get a cleaner starting point for content briefs and topic maps.How do you group thousands of keywords into topics without doing it by hand? Simone De Palma, a Technical SEO Manager at TUI UK Limited, published a refactored Python script on July 30, 2026, that answers exactly that question. It matters now because content teams working with large keyword exports need a faster way to plan around topics instead of sorting rows in a spreadsheet one by one.
Why Manual Keyword Grouping Breaks Down at Scale
De Palma describes staring at a spreadsheet with 12,000 rows and a “group by intent” column filled in by hand. That approach doesn’t scale. Rule-based grouping, where you match keywords by shared words, also fails because it misses phrases that mean the same thing but share no common word. A keyword clustering tool with Python solves both problems by grouping keywords based on meaning, not just matching text. For teams that would rather skip the manual sorting altogether, platforms like WriterZen offer algorithm-driven keyword clustering out of the box, taking on the same grouping task without requiring anyone to build a script from scratch.
How the Keyword Clustering Tool with Python Actually Works
The script uses two techniques together. First, TF-IDF vectorization turns each keyword into a number-based vector. TF-IDF stands for term frequency-inverse document frequency, a method that gives more weight to words that stand out in your dataset and less weight to words that show up everywhere. Second, HDBSCAN, a density-based clustering algorithm, groups those vectors into clusters. Unlike k-means, HDBSCAN doesn’t require you to state the number of clusters ahead of time. This matters because you rarely know how many topics exist in your keyword list until after you’ve explored it.
Handling Outlier Keywords Without Forcing a Fit
HDBSCAN labels keywords that don’t belong anywhere as -1, marking them as noise instead of stuffing them into the nearest cluster. This helps with long-tail queries, the very specific, low-volume search terms that don’t fit a broader topic. Instead of dragging down cluster quality by placing these terms somewhere they don’t belong, the tool sets them aside. The result is a cleaner set of topics for your content team to work from.
Sourcing Keywords from Google Search Console and BigQuery
De Palma recommends pulling keyword data from BigQuery instead of the Search Console interface. The standard interface caps results at 1,000 rows and applies sampling, which limits what you see. A BigQuery export avoids both limits. You export the query column as a CSV, save it as a .txt file with one keyword per line, and feed that into the notebook.
Running the Keyword Clustering Tool with Python in Google Colab
The rebuilt version runs as a Google Colab notebook instead of a terminal script, since the actual workflow is “pull keywords, run notebook, hand a client a file.” It adds tunable parameters for cluster sensitivity and minimum cluster size, so you can adjust results based on whether you’re clustering 50 keywords or 50,000. It also uses Plotly for visualization. Output comes as an Excel file with a grouped cluster view and a full keyword-by-keyword breakdown, with each cluster labeled by its most distinctive terms.
If you already export Search Console data into BigQuery, add this step to your workflow: pull your queries, run the clustering, and review the groups before you brief your content team. The tool won’t replace your judgment on what topics matter, but it will save you hours of manual sorting and give you a clearer starting point. If you’d rather not build and maintain your own Python notebook, tools like WriterZen automate keyword clustering with a built-in algorithm, turning raw keyword exports into organized topic groups without touching a spreadsheet.


















