0

Input

         col           ts
row     
65536   [592]         [2019-04-24 22:33:11]
65537   [576, 592]    [2019-04-25 04:37:13, 2019-04-25 04:37:14]
65538   [592]         [2019-04-25 04:37:13]
65539   [576, 592]    [2019-04-25 01:33:49, 2019-04-25 01:33:49]
65540   [592]         [2019-04-25 01:33:49]

I need a transformation to make the output as

         col           ts
row     
65536    592           2019-04-24 22:33:11
65537    576           2019-04-25 04:37:13
65537    592           2019-04-25 04:37:14
65538    592           2019-04-25 04:37:13
65539    576           2019-04-25 01:33:49
65539    592           2019-04-25 01:33:49
65540    592           2019-04-25 01:33:49

In every row, col has a list that has the same length with a list in ts

ComplicatedPhenomenon
  • 4,055
  • 2
  • 18
  • 45
  • Try this out ```list_cols = {'col','ts'} exploded = [df[col].explode() for col in list_cols] new_df = pd.DataFrame(dict(zip(list_cols, exploded)))``` – A DUBEY Mar 02 '21 at 10:41
  • You are looking for this: df.set_index(['row']).apply(pd.Series.explode).reset_index() – Chiel Mar 02 '21 at 10:44

0 Answers0