df_test = pd.DataFrame(
data=[
[[0,1]],
[[1,0]]
],
columns=['col']
)
df_result = pd.DataFrame(
data=[
[0,1],
[1,0]
],
columns=['col1', 'col2']
)
# 如何将df_test['col']中的list对象拆分为两列, 使结果为df_result
pd.DataFrame(df_test['col'].to_list(), columns=['col1', 'col2'])
df_test['col'].apply(pd.Series).rename(columns={0: 'col1', 1: 'col2'})
标签:df,col2,list,result,pd,test,col,columns
From: https://blog.51cto.com/u_16055028/7859998