I have a Dataframe with columns that look like this:
df=pd.DataFrame()
df['symbol'] = ['A','B','C']
df['json_list'] = ['[{name:S&P500, perc:25, ticker:SPY, weight:1}]',
'[{name:S&P500, perc:25, ticker:SPY, weight:0.5}, {name:NASDAQ, perc:26, ticker:NASDAQ, weight:0.5}]',
'[{name:S&P500, perc:25, ticker:SPY, weight:1}]']
df['date'] = ['2022-01-01', '2022-01-02', '2022-01-02']
df:
symbol json_list date
0 A [{name:S&P500, perc:25, ticker:SPY, weight:1}] 2022-01-01
1 B [{name:S&P500, perc:25, ticker:SPY, weight:0.5... 2022-01-02
2 C [{name:S&P500, perc:25, ticker:SPY, weight:1}] 2022-01-02
The values in the json_list
column are of <class 'str'>
.
How can I convert the json_list
column items to dicts so I can access them based on key:value pairs?
Thank you in advance.