Python Pandas: Using 'apply' to apply 1 function to multiple columns
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Quick Pandas DataFrame question... Just a conceptual question Let's say I have a 3 column DataFrame. Call it df : A B C 0 1 2 3 1 1 2 3 2 1 2 3 3 1 2 3 4 1 2 3 Now let's say I have a function f(A,B,C) , which in theory would take columns A , B , and C as inputs. For example, def function(A,B,C): return (A+1, B/2, C*3) This function returns a tuple, of course. Essentially, I'd like to know if I could apply function to df to get the following output: A B C 0 2 1 9 1 2 1 9 2 2 1 9 3 2 1 9 4 2 1 9 If so, how would I do that? I can't just type df