Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def defined_value(df, col1, col2, col3):
- for row in df.itertuples():
- col1 = 'Col1'
- result = row.col1 + row.col2 + row.col3
- if result > 10:
- return str('Result > 10: ', result)
- df.loc[:, 'test_1'] = defined_value(df, 'Col1', 'Col2', 'Col2')
- ---------------------------------------------------------------------------
- AttributeError Traceback (most recent call last)
- <ipython-input-27-a0908c223773> in <module>()
- ----> 1 df.loc[:, 'test_1'] = defined_value(df, 'Col1', 'Col2', 'Col2')
- <ipython-input-26-6194bd333695> in 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)
- AttributeError: 'Pandas' object has no attribute 'col1'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement