Machine learning

Stage 1 · Lesson 9 of 9

Working with text in Python

Python for data

Text work starts with plain Python strings. Learn slicing, split and join, , and reading files with an explicit encoding="utf-8". Python strings are , so Urdu, Arabic and emojis are all just characters, but the same letter can be stored in more than one way, which unicodedata.normalize fixes.

Regular expressions, the re module, find patterns such as phone numbers, URLs and repeated letters. In pandas the .str accessor applies these to a whole column at once. Practise on real messy text: product reviews, tweets or support messages in more than one language.

Common trapcleaning too hard, such as lowercasing everything and stripping punctuation and emojis, before you know whether they carry meaning for your task.

A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock

Resources for this stage

Start with· follow one of these

Practise

  • The Python, Pandas and Data Visualization micro courses, in browser notebooks

Keep handy

  • Start with 10 minutes to pandas, then look up indexing, groupby and reshaping

  • Quick NumPy, pandas and Matplotlib lookups with a try-it editor

Mark this stage as not done?