1

I have an input as follows (tried to get the formatting right)

**key**   **value**

   'A'         63

   'B'        87.2

   'D'        1.4

   'E'       15.6

I need to convert this to [['A', 63],['B',87.2],['D',1.4],['E',15.6]] so that this can be stored in a cell, in an aggregation dataframe

I tried the following

   element_flatten=[]
     for ele in inputdataframe.itertuple(index=False):
     element_flattened=element_flattened +[ele]code here

I get something like [Pandas(key='A', value=63), Pandas(key='B', value=87.2)] - while what I would like is just [[A,63],['B',87.2]] etc

Dani Mesejo
  • 61,499
  • 6
  • 49
  • 76
raghu
  • 339
  • 2
  • 12

1 Answers1

1

Try using values:

print(inputdataframe.values.tolist())

Output:

[['A', 63], ['B', 87.2], ['D', 1.4], ['E', 15.6]]
U13-Forward
  • 69,221
  • 14
  • 89
  • 114