0

I have a list of lists of dataframes like this:

data_outer
Out[52]: 
[[    VSM   test   NA hit fail
  0  VSM1  test1  425   0    1],
  [    VSM   test   NA hit fail
  0  VSM1  test2  425   0    1]]

and would like to convert this to a pandas dataframe.

df<-pd.DataFrame(data_outer) 

yields a dataframe with two rows where each row consists of one list of data_outer.

How would I convert this into a single pd. dataframe with VSM, test hit an fail as column numbers and VSM1, test1,425, 0,1 as entrys in row0?

And if my df is even more stacked like say:

    Out[52]: 
[
[[    VSM   test   NA hit fail
  0  VSM1  test1  425   0    1],
  [    VSM   test   NA hit fail
  0  VSM1  test2  425   0    1]]
 [[    VSM   test   NA hit fail
  0  VSM2  test1  425   0    1],
  [    VSM   test   NA hit fail
  0  VSM2  test2  425   0    1]]]

Is there a simple approach to convert this?

la_lo_ca
  • 11
  • 2
  • `pd.concat(data_outer)` or, if nested `pd.concat(flatten(data_outer))` with `flatten` any function that can flatten a nested list (see duplicates). – mozway Aug 04 '23 at 12:36

0 Answers0