Python Pandas iterate over rows and access column names - Stack Overflow

PHOTO EMBED

Sun Oct 11 2020 07:56:44 GMT+0000 (Coordinated Universal Time)

Saved by @arielvol #python

start_time = time.clock()
result = 0
for row in df.itertuples(index=False):
    result += max(row[df.columns.get_loc('B')], row[df.columns.get_loc('C')])

total_elapsed_time = round(time.clock() - start_time, 2)
print("4. Polyvalent Itertuples working even with special characters in the column name done in {} seconds, result = {}".format(total_elapsed_time, result))
content_copyCOPY

https://stackoverflow.com/questions/43619896/python-pandas-iterate-over-rows-and-access-column-names/43620031