Python 用pandas逐行读取DataFrame

import pandas as pd

dict=[[1,2,3,4,5,6],[2,3,4,5,6,7],[3,4,5,6,7,8],[4,5,6,7,8,9],[5,6,7,8,9,10]]

data=pd.DataFrame(dict)

print(data)

for indexs in data.index:

print(data.loc[indexs].values[0:-1])

实验结果:

   0 1 2 3 4 5

0 1 2 3 4 5 6

1 2 3 4 5 6 7

2 3 4 5 6 7 8

3 4 5 6 7 8 9

4 5 6 7 8 9 10

[1 2 3 4 5]

[2 3 4 5 6]

[3 4 5 6 7]

[4 5 6 7 8]

[5 6 7 8 9]

猜你喜欢

转载自www.cnblogs.com/ymsong/p/12632735.html