title: Why does pandas.DataFrame.apply produces Series instead of DataFrame
body: <p>I do not really understand why from the following code pandas return is Series but not a DataFrame.</p>
  <pre><code>import pandas as pd
  df = pd.DataFrame([[4,9]]*3, columns = [&quot;A&quot;, &quot;B&quot;])
  
  def plus_2(x):
      y =[]
      for i in range(0, len(x)):
          y.append(x[i]+2)
      return y
  
  df_row = df.apply(plus_2, axis = 1) # Applied to each row
  df_row
  
  </code></pre>
  <p>While if I change <code>axis=0</code> it produces DataFrame as expected:</p>
  <pre><code>import pandas as pd
  df = pd.DataFrame([[4,9]]*3, columns = [&quot;A&quot;, &quot;B&quot;])
  
  def plus_2(x):
      y =[]
      for i in range(0, len(x)):
          y.append(x[i]+2)
      return y
  
  df_row = df.apply(plus_2, axis = 0) # Applied to each row
  df_row
  
  </code></pre>
  <p>Here is the output:</p>
  <p><a href="https://i.stack.imgur.com/dRotK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dRotK.png" alt="enter image description here" /></a></p>