Thank you for response!
I’ve tried it out and it seems like the problem starts to appear when I add ‘if’ statement. I can’t see the error.
I followed this lesson, yet I still getting the error.
I also tried to make sure that the lambda function is the culprit, and it seems that it is:
func = lambda row: row.product_description if row.location == 'Brooklyn' and row.product_type == 'seeds'
seed_request = inventory['location', 'product_type', 'product_description'].apply(func, axis=1)
print(seed_request)
Outputs:
File "script.py", line 11
func = lambda row: row.product_description if row.location == 'Brooklyn' and row.product_type == 'seeds'
^
SyntaxError: invalid syntax
Ok, so I’ve been playing with lambdas in the terminal because this wasn’t sitting right with me.
It’s a syntax thing, lambda: 4 if True yields an error while lambda: 4 if True else False is a perfectly kosher expression. I guess every if requires an else with lambdas.
adding an and statement should work: lambda: 4 if True and 'four' else False