📜  在数据框行上循环python代码示例

📅  最后修改于: 2022-03-11 14:47:00.728000             🧑  作者: Mango

代码示例1
for index, row in df.iterrows():
    print(f'Index: {index}, row: {row.values}')

for index, row in df.iterrows():
    print(f'Index: {index}, column_a: {row.get("column_a", 0)}')

for row in df.itertuples():
    print(row)

# But !
# The .apply() function provides a more efficient
# method for updating a DataFrame.
# see : https://towardsdatascience.com/pandas-apply-for-power-users-f44d0e0025ce