Guided Notes
Transform: Data Types, Dates & Encodings
Fixing data types, converting text to numbers, parsing dates, and reading files with unusual encodings.
Why data types matter
Slide 1 / 5pandas assigns each column a dtype: int64, float64, bool, datetime64, or object/string for text. The type decides what operations do.
The projects data was read with dtype=str, so totalamt is text. Adding text joins it together:
df_projects['totalamt'].sum() β '0200000000580000000β¦' β one giant string, not a total.
The population data, read normally, got sensible types: names as text, years as floats. Always check df.dtypes after extracting.
