Iterate over pandas dataframe columns containing nested arrays

前端 未结 4 1706
情话喂你
情话喂你 2021-01-21 01:46

I hope you can help me with this issue,

I\'ve this data below (Columns names whatever)

data=([[\'file0090\',
    ([[ 84,  55, 189],
   [248, 100,  18],
         


        
4条回答
  •  广开言路
    2021-01-21 02:12

    We can do explode with row the do it explode with column again

    s = pd.DataFrame(data).set_index(0)[1].explode()
    df = pd.DataFrame(s.tolist(), index = s.index.values)
    
    df
    Out[396]: 
                0    1    2
    file0090   84   55  189
    file0090  248  100   18
    file0090   68  115   88
    file6565   86   58  189
    file6565   24   10  118
    file6565   68   11    8
    

提交回复
热议问题