1

I have following data in dataframe

           From                        To
          [time]                       clock time
          [year]                       twelvemonth, yr
          [people]                     None
          [way]                        means, agency
          [lily]                       flower
          [man]                        homo, human being, human
          [man]                        adult male, male
          [case]                       instance, example
          [case]                       lawsuit, suit, cause, causa
          [case]                       display case, showcase, vitrine

What i want is spliting it from "," in TO Column and creating seperate row for each entry so the expected outout will be

               From                        To
              [time]                       clock time
              [year]                       twelvemonth
              [year]                       yr
              [people]                     None
              [way]                        means
              [way]                        agency
              [lily]                       flower
              [man]                        homo
              [man]                        human being
              [man]                        human
              [man]                        adult male
              [man]                        male
              [case]                       instance
              [case]                       example
              [case]                       lawsuit
              [case]                       suit
              [case]                       cause
              [case]                       causa                              
              [case]                       display case
              [case]                       showcase
              [case]                       vitrine

My data is in Dataframe format I have tried this but this does not help

b = pd.concat([pd.Series(row['From'], row['To'].split(','))
               for _, row in df.iterrows()]).reset_index()

Can any one help doing this?

Cyley Simon
  • 253
  • 2
  • 5
  • 17

0 Answers0