[Python] Cleaning CITY column with python

Discussão em 'Python' iniciado por Stack, Março 4, 2025.

  1. Stack

    Stack Membro Participativo

    I hope you’re all doing well! I could really use your expertise with a little challenge I’m facing. I have a table with about 55,578 rows containing postcodes and cities, and I need to clean up the cities column.

    While I’m comfortable handling spaces and symbols, I’m stuck on a specific issue. Many rows have the city names mixed with province names or even country names, like "Sabadell Barcelona" or "TerrassaBarcelona." What I really need is to extract just the city names, like "Sabadell" for the province of Barcelona or simply "Terrassa."

    If anyone has any tips or suggestions on how to tackle this, I would greatly appreciate it! Thank you so much for your help!

    I,ve tried with patterns and chatgpt or gemini

    Continue reading...

Compartilhe esta Página