How to find the count of spaces in a dataframe using python
--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzling Curiosities
--
Chapters
00:00 How To Find The Count Of Spaces In A Dataframe Using Python
00:27 Accepted Answer Score 3
00:44 Thank you
--
Full question
https://stackoverflow.com/questions/6937...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #pandas
#avk47
    Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzling Curiosities
--
Chapters
00:00 How To Find The Count Of Spaces In A Dataframe Using Python
00:27 Accepted Answer Score 3
00:44 Thank you
--
Full question
https://stackoverflow.com/questions/6937...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #pandas
#avk47
ACCEPTED ANSWER
Score 3
Use Series.str.count with \s+ for match spaces:
df['count'] =df['Key'].str.count('\s+')
print (df)
                      Key  count
0              Identifier      0
1       Identifier Number      1
2  user identifier number      2
3                    user      0
4        Location of user      2