title: Applying a function to an entire DataFrame in Pandas
body: <p>Probably a trivial question, but how does one apply a function to an entire "matrix" with Pandas? It seems to me that apply either works row-wise or column-wise, but what if I want to do both? E.g.</p>
  
  <pre><code>&gt;&gt;&gt; df = pd.DataFrame({"A": [10,20,30], "B": [20, 30, 10]})
  &gt;&gt;&gt; df
      A   B  
  0  10  20         
  1  20  40         
  2  30  10  
  &gt;&gt;&gt; df.apply(max)
  40
  </code></pre>
  
  <p>With some pre-defined max function. Many thanks in advance</p>
  
  <p>Edit:
  Apologies, I should have been more clear in my original question. I am not actually interested in calculating a DataFrame max, rather it was just meant as an example. Perhaps a better example, would be a function that takes the max of the last two rows over both columns, ie.</p>
  
  <pre><code>&gt;&gt;&gt; df = pd.DataFrame({"A": [10,20,30], "B": [20, 30, 10]})
  &gt;&gt;&gt; df
      A   B  
  0  10  20         
  1  20  40         
  2  30  10 
  3  50  20 
  &gt;&gt;&gt; df.apply(max)
  0  n/a
  1  40
  2  40
  3  50
  </code></pre>