0

I have a dataframe. This dataframe holds ts data

Every column is a dimension in my ts data. Every row holds an indidual time series. Ts that i have are not eual in length. Structure of my dataframe

I want each element in my dataframe to be converted to a series instead. Meaing that i will still have the same number of rows and same number of columns. However instead the type of each element is an array it will be pandas series

Aslo note that i am trying to change it to that structure to use MiniRocketMultivariateVariable from sktime

I tried using the apply method but no luckdf = df.applymap(pd.Series) I also tried to change it using pd.series by creating another column df['col_3'] = pd.Series(df['dim_1']) However the elements of the new column is still a list type

The ouput that i would like is a dataframw with the same number of columns and same number of rows. However each element is a pandas series instead of a list an example of the structure is belowdesired structure

1 Answers1

1

Something like this?

d = {'dim_1' : [[0,1,2,3,4.34,5,6], [0.234,1,2,3,4,5,7]], 'dim_2' : [[0,1.24,2,3,3,4,5], [0,1,2,3,4.67,5,6]]}
df_series = pd.DataFrame(d)


def test(series):
     a = " ".join(f"{i}" for i in series)
     return a
    
x = df_series.applymap(test)
df_series = x
df_series

Output:

          dim_1               dim_2
0   0 1 2 3 4.34 5 6    0 1.24 2 3 3 4 5
1   0.234 1 2 3 4 5 7   0 1 2 3 4.67 5 6
Galo Torres Sevilla
  • 1,540
  • 2
  • 8
  • 15