0

I have the current data:

NAME
Andrew        ([1], [0], [100])
Sam           ([1, 2, 3, 4], [0, 0, 0, 0], [100, 100, 100, 100])
Susan         ([1, 2, 3, 4,5], [1, 2, 3, 4, 5], [50, 100, 100, 25, 20])

And I would like to turn them into columns of a dataframe, but am struggling to find a simple command. Usually, I would save them to a list, but want to know if there is simple way of doing this. Each list within a tuple for Name would be considered a row in the dataframe Thanks.

    Name        column1   column2  column3
    Andrew         1          0       100
    Sam            1          0       100  
    Sam            2          0       100
    Sam            3          0       100
    Sam            4          0       100
    Susan          1          1       50

smci
  • 32,567
  • 20
  • 113
  • 146
AndronikMk
  • 151
  • 1
  • 10
  • what's behind `...`? Are they all 3-tuples or are they different sizes? What to make of Susan's data? Is it just a single long list? You need to be more specific here –  Jan 20 '22 at 01:13
  • They are all tulples. Each tuple contains three lists of the same length. – AndronikMk Jan 20 '22 at 01:19
  • so could you update your question to reflect that? –  Jan 20 '22 at 01:20
  • Just updated it. – AndronikMk Jan 20 '22 at 01:28
  • 1
    **`df.explode()`**. This is a duplicate. Not of [this](https://stackoverflow.com/questions/62322092/converting-tuples-in-a-row-to-a-new-columns-in-pandas-dataframe) but of e.g. [Explode Cell into Multiple Rows in Pandas](https://stackoverflow.com/questions/65799353/explode-cell-into-multiple-rows-in-pandas/). Or all the other questions on exploding tuples. – smci Jan 20 '22 at 01:48

0 Answers0