I want to read in a CSV file with pandas. Two columns are to be multiplied by a different constant each.
params = {
"table-columns": ['A', 'B'],
"multiplicands": ['0.001', '0.000001']
}
converters_ = {}
for i in range(0,len(params['table-columns'])):
column = params['table-columns'][i]
multiplicand = params['multiplicands'][i]
display(column + '/' + multiplicand)
func = lambda x: float(x) * float(multiplicand)
converters_[column] = func
display(converters_['A'](1)) # should be 1e-03
display(converters_['B'](1)) # should be 1e-06
#df = pd.read_csv('data.csv', converters=converters_)
This is the output:
'A/0.001'
'B/0.000001'
1e-06
1e-06
Column A should be multiplied by 0.001, but it is multiplied by 0.000001. Where is the bug here?