0

I'm trying to window my data frame so I made a for loop as the code below:

m=6
p=0
Window=[]
for i in list2:
    l=df3S.iloc[i:i+k,:]
    j=df3S.iloc[i+m:i+(3*m),:]
    Window.append(l)
    Window.append(j)
    i+=k

so I have a list of data sets right now but I need a multi-index data frame to do some analysis on it but when I convert it to a data frame by

pd.DataFrame()

it returns me just the empty columns like this:

                      0
____________________________
0   Date Node Ax Ay Az Gx...
1   Date Node Ax Ay Az G...
2   Date Node Ax Ay Az G...
3   Date Node Ax Ay Az G...
4   Date Node Ax Ay Az G...
...     ...
41003   Date Node Ax Ay ...
41004   Date Node Ax Ay ...
41005   Date Node Ax Ay ...
41006   Date Node Ax Ay ...
41007   Date Node Ax Ay ...

I don't know how to fix it this is the output of my list: [1]: https://i.stack.imgur.com/Ek4li.png

I have written the following code to store my for loop in a data frame like this:

k=12
m=6
p=0
Window=pd.DataFrame()
for i in list2:
    l=df3S.iloc[i:i+k,:]
    j=df3S.iloc[i+m:i+(3*m),:]
    Window[str(l)]=l
    Window[str(l)]=j
    i+=k

but it returns me this error:

ValueError :Cannot set a frame with no defined index and a value that cannot be converted to a Series

1 Answers1

0

Use:

df = pd.concat(Window, ignore_index=True)
jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252
  • thanks. but want all my data frame elements in my list to be recognized as a row in my new data frame like the data frame of data frames. it just concatenate them – Hoda Nayebi Nov 02 '21 at 07:59
  • @HodaNayebi - Hi. Please take the time to read this post on [how to provide a great pandas example](http://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) as well as how to provide a [minimal, complete, and verifiable example](http://stackoverflow.com/help/mcve) and revise your question accordingly. These tips on [how to ask a good question](http://stackoverflow.com/help/how-to-ask) may also be useful. – jezrael Nov 02 '21 at 08:00