iterate over rows dataframe
df = pd.DataFrame([{'c1':10, 'c2':100}, {'c1':11,'c2':110}, {'c1':12,'c2':120}])
for index, row in df.iterrows():
print(row['c1'], row['c2'])
iterate over rows dataframe
df = pd.DataFrame([{'c1':10, 'c2':100}, {'c1':11,'c2':110}, {'c1':12,'c2':120}])
for index, row in df.iterrows():
print(row['c1'], row['c2'])
loop on dataframe lines python
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
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us