how can I rewrite this code without for loop?

喜欢而已 提交于 2019-12-13 04:26:54

问题


I want to rewrite this code whithout for loops.

for x in range(round(len(data)/128)):
  for i in range(128):
    data.iloc[x*128 , i*24:(i+1)*24] = data.iloc[(x*128)+i , 0:24].values

This code moves data of 128 rows to one row(move index 1:127 -> index 0) and (index 128:255 -> index 128) and ...)). How can I rewrite it optimally?

来源:https://stackoverflow.com/questions/58141412/how-can-i-rewrite-this-code-without-for-loop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!