I am trying to dynamically add datatype objects to a dictionary, in order to specify the 'dtype' argument in the pd.read_csv function.
The problem is that simply passing 'key' : str or 'key' : float to dict.update() does not preserve the datatype objects and has no effect on the dtype argument.
I have attempted the following:
for column in list_of_columns:
dict.update({column : str})
I expected to see something like:
{
'a' : str,
'b' : str,
'c' : str
}
But instead it produces:
{
'a' : <class 'str'>,
'b' : <class 'str'>,
'c' : <class 'str'>
}
Is there any way that I can explicitly place that datatype object in the dictionary?