Convert a string of list of ordereddict to a list with dictionaries

I have a dataframe in which every row contains a string like the following:

"[OrderedDict([('id', 946), ('product', 'CRT6423'), ('quantity', 1)]), 
 OrderedDict([('id', 947), ('product', 'CIN1199B'), ('quantity', 1)]), 
 OrderedDict([('id', 948), ('product', 'CSS001'), ('quantity', 2)])]"

This is in string format.

I want to convert this into a list of dictionaries for which I am using literal_eval but it gives me the following error":

ValueError: malformed node or string: <_ast.Call object at 0x00000175D77D9DF0>

Expected output:

[{"product":"CRT6423", "quantity":1},
{"product":"CIN1199B", "quantity":1},
{"product":"CSS001", "quantity":2}]
Back to Top