I'm trying to read a .csv with a column containing numbers in scientific notation. No matter what I do, it ends up reading them as string:
def readData(path, cols):
types = [str, str, str, str, np.float32]
t_dict = {key: value for (key, value) in zip(c, types)}
df = pd.read_csv(path, header=0, sep=';', encoding='latin1', usecols=cols, dtype=t_dict, chunksize=5000)
return df
c = [3, 6, 7, 9, 16]
df2017_chunks = readData('Data/2017.csv', c)
def preProcess(df, f):
df.columns = f
df['id_client'] = df['id_client'].apply(lambda x: str(int(float(x))))
return df
f = ['issue_date', 'channel', 'product', 'issue', 'id_client']
df = pd.DataFrame(columns=f)
for chunk in df2017_chunks:
aux = preProcess(chunk, f)
df = pd.concat([df, aux])
How can I proper read this data?