loop on dataframe lines python

Solutions on MaxInterview for loop on dataframe lines python by the best coders in the world

showing results for - "loop on dataframe lines python"
Enrico
26 May 2017
1for index, row in df.iterrows():
2    print(f'Index: {index}, row: {row.values}')
3
4for index, row in df.iterrows():
5    print(f'Index: {index}, column_a: {row.get("column_a", 0)}')
6
7for row in df.itertuples():
8    print(row)
9
10# But !
11# The .apply() function provides a more efficient
12# method for updating a DataFrame.
13# see : https://towardsdatascience.com/pandas-apply-for-power-users-f44d0e0025ce