For a school project I'm working on the kickstarter dataset on Kaggle; https://www.kaggle.com/kemical/kickstarter-projects
In the "name" variable there's a few titles that have spaces in between them; e.g. instance 373 "C R O S S T O W N".
I've been working on some regex all day to re.sub the extra spaces and try to get it to look as a normal word. Though I think this is a problem that occurs more often, most regex content is to add spaces, or add double-spaces. Never this specific task.
I've tried a couple of ways to describe the exact kind of space that needs te be deleted, single out the characters to keep as a group, and using them as the replace string. Though it looks like it should be working, my data doesn't change.
- long regex expression written to identify words that are written as spaces + single capitals (tried a couple of different ones for this)
- r'\2\4' refers to the second and fourth group (the first and second alphabetic character)
Names_fixed = []
for i in Name_New:
Names_fixed.append(re.sub(r'(\s|^)([A-Z])(\s)(A-Z)\s/g', r'\2\4', i))
As I'm still pretty new to regex, turning to the community for help; thanks a lot in advance.