Create lines from the index of a Python series or dataframe

Asked

Viewed 40 times

3

I created this dataframe:

x = [1,3,5,8,10,15,4,5,6,8,23,12,28]  
x = pd.DataFrame(x)

I created the following dataframe:

inserir a descrição da imagem aqui

I created a new dataframe with the following code:

z = []
for i in range(len(x)):
    z.append(x[i:i+3])

And I got the following:

inserir a descrição da imagem aqui

I would like to create a Dataframe where instead of the series go from the "i:i+3" would be something like "i:i==5", ie the final value would not be three forward indexes, but the value "5" of the column. I don’t know what code is used to get that list

  • What is the problem there to be pending? already modified and did not help

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.