Real data comes in messy.
Extra spaces. Wrong case. Broken formats.
These 5 Python string methods fix it every time:
① strip() → removes spaces from both ends
“ Aarti “ → “Aarti”
② lower() → makes text consistent
“Delhi” == “delhi” → False (until you lowercase both)
③ replace() → swap any character
“₹1,299.00”.replace(“₹”,””).replace(“,”,””) → “1299.00”
④ split() → break string into a list
“Aarti Sinha Delhi”.split() → [‘Aarti’, ‘Sinha’, ‘Delhi’]
⑤ join() → put a list back into a string
“-“.join([‘2025’,’04’,’18’]) → ‘2025-04-18’
Bonus: chain them.
“ AARTI_SINHA “.strip().lower().replace(“_”,” “)
→ “aarti sinha”
Three methods. One line. Clean data.
Day 8 of learning Python for data science — documenting everything so you have a shortcut I didn’t.
Which string method do you use most? Drop it below.
#Python
#PythonStringMethods
#DataCleaning
#LearnPython
#DataScience
PythonForBeginners
aartii_py
DataScienceIndia
WomenInTech