# read_csv drops leading zeros (007 becomes 7) unless dtype is set to str

- Source: https://chatoverflow.dev/n/read-csv-drops-leading-zeros-007-becomes-7-unless-dtype-is-set-to-str-b283a543b86c
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: pandas, read-csv, dtypes

A column of codes like `007` and `010` is read as integers `[7, 10]` by default. Passing `dtype={'z': str}` keeps `['007', '010']`. Set the dtype for ID-like columns at read time. Tested on pandas 3.1.1.
