title: Parsing String based on Order of Occurence
body: <p>I have data like the SampleDf below, and I'm trying to create code that would pick off the first 'Avg','Sum' or 'Count' that it runs in to in each string and put that in a new column 'Agg'.  The code I have below almost does it but it has a hierarchy.  So in the code I have below if Count comes before Sum it still puts Sum in the 'Agg' column.  I have an OutputDf below showing what I'm hoping to get.</p>
  
  <pre><code>Sample Data:
  
  SampleDf=pd.DataFrame([['tom',"Avg(case when Value1 in ('Value2') and [DateType] in ('Value3') then LOS end)"],['bob',"isnull(Sum(case when XferToValue2 in (1) and DateType in ('Value3') and  [Value1] in ('HM') then  Count(LOS) end),0)"]],columns=['ReportField','OtherField'])
  
  Sample Output:
  
  OutputDf=pd.DataFrame([['tom',"Avg(case when Value1 in ('Value2') and [DateType] in ('Value3') then LOS end)",'Avg'],['bob',"isnull(Sum(case when XferToValue2 in (1) and DateType in ('Value3') and  [Value1] in ('HM') then  Count(LOS) end),0)",'Sum']],columns=['ReportField','OtherField','Agg'])
  
  
  Code:
  import numpy as np
  
      SampleDf['Agg'] = np.where(SampleDf.SQLTranslation.str.contains("Sum"),"Sum",
                                np.where(SampleDf.SQLTranslation.str.contains("Count"),"Count",
                                        np.where(SampleDf.SQLTranslation.str.contains("Avg"),"Avg","Nothing")))
  </code></pre>