I have a dataframe like so:
name: ... line:
bobo ... 10
amy ... 5
amanda ... 15
I want to create a function that can be used for multiple dataframes, which adds new columns to the dataframe based on the calculations within the function. This is what I am trying to do with the function, but it isn't working.
def check(df, lines):
for line in lines:
df['big_line'] = (line*5, line)
df['small_line'] = line*2
df['massive_line'] = line*10
df['line_word'] = line + ' line'
return df
Essentially, what I am trying to get it to return is the dataframe looking like this:
Function call:
def check(df, df['line'])
Return:
name: ... line: big_line: small_line: massive_line: line_word:
bobo ... 10 (50, 10) 20 100 10 line
amy ... 5 (25, 5) 10 50 5 line
amanda ... 15 ...............................................
If someone could point me in the right direction that would be great. Thanks.
I am getting an error with big_line because it is tuple sort of object.