I have to change string to list that contains dicts. When I try to make eval
function on one discrite value in my dataframe, the value perfectly converts. Problem is when when I want to make it on each row in the loop.
In:
df_clean['CalculatedData.AnchorLayoutPoints'][234]
Out:
"[{'X': -114.3, 'Y': -114.3, 'IsSlotted': False}, {'X': 114.3, 'Y': -114.3, 'IsSlotted': False}, {'X': -114.3, 'Y': 114.3, 'IsSlotted': False}, {'X': 114.3, 'Y': 114.3, 'IsSlotted': False}]"
In:
list(eval(df_clean['CalculatedData.AnchorLayoutPoints'][234]))
Out:
[{'X': -114.3, 'Y': -114.3, 'IsSlotted': False},
{'X': 114.3, 'Y': -114.3, 'IsSlotted': False},
{'X': -114.3, 'Y': 114.3, 'IsSlotted': False},
{'X': 114.3, 'Y': 114.3, 'IsSlotted': False}]
In:
for x in range(df_clean['CalculatedData.AnchorLayoutPoints'].shape[0]):
string = df_clean['CalculatedData.AnchorLayoutPoints'][x]
df_clean['CalculatedData.AnchorLayoutPoints'][x] = list(eval(string))
In:
df_clean['CalculatedData.AnchorLayoutPoints'][234]
Out:
"[{'X': -114.3, 'Y': -114.3, 'IsSlotted': False}, {'X': 114.3, 'Y': -114.3, 'IsSlotted': False}, {'X': -114.3, 'Y': 114.3, 'IsSlotted': False}, {'X': 114.3, 'Y': 114.3, 'IsSlotted': False}]"
What's wrong here?