I have code that reads a CSV like this:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import pandas as pd
csv_path = 'test.csv'
df = pd.read_csv(csv_path, delimiter=';', quotechar='"',
decimal=',', encoding="ISO-8859-1", dtype={'FOO': str})
df.FOO = df.FOO.map(lambda n: n.zfill(6))
and I get
AttributeError: 'float' object has no attribute 'zfill'
so obviously, Pandas interpreted the column FOO
as a number. It is numeric, but I don't want to interpret it as a number
(I know that df.FOO = df.FOO.map(lambda n: str(n).zfill(6))
makes the problem go away, but I would like to know why this problem occurs in the first place.)
I use pandas 0.20.3.
Example CSV
FOO;BAR
01,23;4,56
1,23;45,6
;987