0
我期待在Python中數據幀的指標申請一個循環迭代數據幀的行, 我的循環就好 的指數數據幀: 如果指數< = 10 指數=指數+ 1個 回報行(索引)如何使用指數
我期待在Python中數據幀的指標申請一個循環迭代數據幀的行, 我的循環就好 的指數數據幀: 如果指數< = 10 指數=指數+ 1個 回報行(索引)如何使用指數
使用DataFrame.iterrows()
:
for row, srs in pd.DataFrame({'a': [1,2], 'b': [3,4]}).iterrows():
...do something...
試試這個:
for index, row in df.iterrows():
if index <=10:
print row
這將打印前10行
對不起,說你的回答沒有幫助 – Anu