Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. def defined_value(df, col1, col2, col3):
  2. for row in df.itertuples():
  3. col1 = 'Col1'
  4. result = row.col1 + row.col2 + row.col3
  5. if result > 10:
  6. return str('Result > 10: ', result)
  7.  
  8. df.loc[:, 'test_1'] = defined_value(df, 'Col1', 'Col2', 'Col2')
  9.  
  10. ---------------------------------------------------------------------------
  11. AttributeError Traceback (most recent call last)
  12. <ipython-input-27-a0908c223773> in <module>()
  13. ----> 1 df.loc[:, 'test_1'] = defined_value(df, 'Col1', 'Col2', 'Col2')
  14.  
  15. <ipython-input-26-6194bd333695> in defined_value(df, col1, col2, col3)
  16. 2 for row in df.itertuples():
  17. 3 col1 = 'Col1'
  18. ----> 4 result = row.col1 + row.col2 + row.col3
  19. 5 if result > 10:
  20. 6 return str('Result > 10: ', result)
  21.  
  22. AttributeError: 'Pandas' object has no attribute 'col1'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement