How to reshape every nth row's data using pandas?

后端 未结 3 1630
余生分开走
余生分开走 2021-01-26 18:37

I need help in reshaping a data in csv file that have over 10000 row by 10 each. For example I have this csv file :

Ale Brick
1   ww
2   ee
3   qq
3   xx
5   dd
         


        
3条回答
  •  失恋的感觉
    2021-01-26 19:01

    import pandas as pd
    
    df = pd.read_csv(`"`test.csv`"`)
    
    data = df['Brick']
    
    k=int(len(data)/10)+1
    
    for x in range(k):
    
        temp=data[10*x:10*(x+1)]
    
        print temp.values.reshape(2,5)
    

提交回复
热议问题