我试图找到解决方案,但没有成功...
vod = pd.read_sql("SELECT * from x", conn)
---------------------------------------------------------------
index id remuneration benefits describe
500 354 1500 example below none
501 355 1200 example below none
502 356 1300 example below none
----------------------------------------------------------------
[{"value":"Insalubre","selected":false},{"value":"Perigoso","selected":false}]
我想在此df =>(Insalubre = false或true)和(Perigoso = false或true)上创建2个新列
type(df['benefits'])
输出:pandas.core.series.Series
输入:
for key, value in df.items():
print(key, value)
输出:
6325 [{"value":"Insalubre","selected":false},{"value":"Perigoso","selected":false}]
输入:
df['benefits']
输出:
0 [{"value":"Insalubre","selected":false},{"valu...
Name: benefits, Length: 6326, dtype: object
我该怎么做才能实现自己的目标?
答案 0 :(得分:0)
这应该有效:
pd.DataFrame(df['benefits'].tolist()[0])