title: Applying function on different part of a Dataframe
body: <p>I need to apply different functions for a database python depending on a slice of this dataframe. Each function creates several columns.</p>
  
  <p>Here is my attempt (very simplified version of course) :</p>
  
  <pre><code>df=pd.DataFrame({'Type':['O','O','A'],'A':[7,9,8],'B':[8,6,5]})
  
  def f1(df):
      df['test']='A-OK'
      df['test2']='A-OK2'
      return df
  def f2(df):
      df['test']='O-OK'
      df['test2']='O-OK2'
      return df
  
  def function_test(df):
      df_a=df[df.Type =='A']
      df_o=df[df.Type =='O']
      #Applying functions
      df_a=f1(df_a)
      df_o=f2(df_o)
  
      #retrieving results
      df[df.Type =='A']=df_a
      df[df.Type =='O']=df_o
  
      return df
  function_test(df)
  </code></pre>
  
  <p>The dataframes df_o and df_a (temporary) contains the good information, but I cannot copy the results in the original df after that.</p>
  
  <p>Edit : Typos corrected</p>