title: Splitting and Appending by Name across two columns in pandas
body: <p>Hello I have a csv file of sports results for the english premier league that I am wanting to manipulate a single team that is located either in a home or away column. I then want to be able to create a series of columns which are sorted by that team and then return the results as per below. I have been able to do this in a loop but would love to know the pandas method. I have attempted to group by team- arsenal, but am finding it difficult to do that with two column options, where i would need to flip subsets of the opposing team.</p>
  
  <pre><code>df = pd.read_csv(
      'http://www.football-data.co.uk/mmz4281/1516/E0.csv', 
      sep=',')
  
  result= df[(df['HomeTeam'] == "Arsenal") | (df.AwayTeam == "Arsenal")]
  
  
  for index, row in result.iterrows():
      if row['HomeTeam'] == "Arsenal":
          if row['FTR'] == "H":
              print ('Win' , 'Home', row['FTHG'], '-', row['FTAG'])
          elif  row['FTR'] == "D":
              print ('Draw' , 'Home', row['FTHG'], '-', row['FTAG'])
          else:
              print ('Lose' , 'Home', row['FTHG'], '-', row['FTAG'])
  
  # we dont need to put the conditons for else because we know if arsenal are not the home team they must be the away team,
  # this is because we already set out dataframe filter above to show only games where arsenal is home or away, if we didnt
  # do this we would do an elif and then do an improper result print for else
      else:
          if row['FTR'] == "H":
              print ('Win' , 'Home', row['FTHG'], '-', row['FTAG'])
          elif  row['FTR'] == "D":
              print ('Draw' , 'Home', row['FTHG'], '-', row['FTAG'])
          else:
              print ('Lose' , 'Home', row['FTHG'], '-', row['FTAG'])
  </code></pre>