Unexpected Scientific Notation with Pandas CSV Data

Bus CSV: Some stop IDs display as scientific notation. How can I convert them to integers? Example:

import pandas as pd; df = pd.read_csv('f.csv', dtype={'s': str}); df.s = [int(x) if x.isdigit() else x for x in df.s]

I experienced a similar issue when trying to preserve the exact stop IDs from CSV files. After reading the file with dtype set to str, converting each entry individually using a lambda function helped maintain the correct formatting. I eventually settled on applying a function with the converters keyword to the column during read_csv. That way, the conversion is done while reading the file and prevents redundant processing steps. It also ensured that large numbers or IDs with leading zeros remain intact without reverting to scientific notation. This approach was effective in my experience.

i tried using the converters param in read_csv to stop the id’s from turning into scietific notation. that way you can keep them as strings and convert later if needed. works fine for me!