Python 如何使用dataframe使用字典列表从列中提取值

Python 如何使用dataframe使用字典列表从列中提取值,python,pandas,Python,Pandas,我有这个数据框 | date | value |------|------| |2020-08-12| [{'action_type': 'video_view', 'value': '527'}]| |2020-08-12|[{'action_type': 'video_view', 'value': '662'}]| |2020-07-01| [{'action_type': 'video_view', 'value': '69'}]| 我想要的输出应该是 | date | value |

我有这个数据框

| date | value
|------|------|
|2020-08-12| [{'action_type': 'video_view', 'value': '527'}]|
|2020-08-12|[{'action_type': 'video_view', 'value': '662'}]|
|2020-07-01| [{'action_type': 'video_view', 'value': '69'}]|
我想要的输出应该是

| date | value
|------|------|
|2020-08-12|527|
|2020-08-12|662|
|2020-07-01|69|

请帮助

如果值列包含数组数据,可以按如下方式提取它:

df['value'] = df['value'].apply(lambda data: data[0].get('value'))

通过使用
str
accessor,您可以轻松做到这一点:

df['value'] = df['value'].str[0].str['value']
如果您需要通过
value
列进行一些数学计算,请不要忘记将类型更改为数字,如下所示:

df['value'] = df['value'].astype(int)