title: Pandas Generating dataframe based on columns being present
body: <p>I have a dataframe</p>
  
  <pre><code>import pandas as pd
  
  df=pd.DataFrame({'Players': [ 'Sam', 'Greg', 'Steve', 'Sam',
                   'Greg', 'Steve', 'Greg', 'Steve', 'Greg', 'Steve'],
                   'Wins': [10,5,5,20,30,20,6,9,3,10],
                   'Losses': [5,5,5,2,3,2,16,20,3,12],
                   'Type': ['A','B','B','B','A','B','B','A','A','B'],
                   })
  </code></pre>
  
  <p>If I wanted to summarize the I can manually make another dataframe:</p>
  
  <pre><code>p=df.groupby('Players')
  
  summary = pd.DataFrame({'Total Games': p.Players.count(),
                          'Average Wins':p.Wins.mean(),
                          'Greatest Wins':p.Wins.max(),
                          'Unique games':p.Type.nunique()})
  </code></pre>
  
  <p>Lets say I want to automate this summarizing process to create a dataframe if column X is present perform summarization Y what would the best way of doing this? I have attempted using a dictionary but I think I did something wrong</p>
  
  <pre><code>p=df.groupby('Players')
  sumdict = {'Total Games': ['Players', p.Players.count()],
              'Average Wins':['Wins', p.Wins.mean()],
              'Greatest Wins':['Wins', p.Wins.max()],
              'Unique games':['Type', p.Type.nunique()],
              'Max Score':['Score', p.Score.max()]}
  
  summary=pd.DataFrame()
  
  for key, value in sumdict.items():
          if value[0] in df.columns:
              data = pd.DataFrame({key: value[1],})
              summary=summary.append(data)
          else:
              continue
  </code></pre>