Relace str method - kind of regex usage doubt

Hi, I don’t get the usage of the str.replace(’\s+’, ’ ') in the page below.

https://app.dataquest.io/m/347/working-with-missing-and-duplicate-data/3/correcting-data-cleaning-errors-that-result-in-missing-values

What is the role of that code?
Check the image below. I don’t see any difference between out[10] and out [12]. I just tried to break it down, I just copied and paste it from Dataquest.

Hello, @italo.moises!

The regex \s+ means “One or more white spaces”. If the result is the same you should use the shorter code, of course:)

1 Like

Thank you.

That helped. :slight_smile:

1 Like