title: How to handle dataframe skipping column in output if None?
body: <p>Dataframe is missing column in output. How do I handle this?</p>
  <p>My code is as below:</p>
  <pre><code>import pandas as pd
  from selenium import webdriver
  from bs4 import BeautifulSoup as bs
  
  browser = webdriver.Chrome()
  
  class GameData:
      def __init__(self):
          self.date = []
          self.time = []
          self.country = []
          self.league = []
          self.game = []
          self.home_odds = []
          self.draw_odds = []
          self.away_odds = []
  
      def append(self, score):
          pass
  
  
  def get_urls(browser, landing_page):
      browser.get(landing_page)
      urls = [i.get_attribute('href') for i in
              browser.find_elements_by_css_selector(
                  '.next-games-date &gt; a:nth-child(1), .next-games-date &gt; a:nth-child(n+3)')]
  
      return urls
  
  
  def parse_data(html):
      df = pd.read_html(html, header=0)[0]
      html = browser.page_source
      soup = bs(html, &quot;lxml&quot;)
      cont = soup.find('div', {'id': 'wrap'})
      content = cont.find('div', {'id': 'col-content'})
      content = content.find('table', {'class': 'table-main'}, {'id': 'table-matches'})
      main = content.find('th', {'class': 'first2 tl'})
  
      if main is None:
          return None
  
      count = main.findAll('a')
      country = count[0].text
      game_data = GameData()
  
      for row in df.itertuples():
          if not isinstance(row[1], str):
              continue
          elif ':' not in row[1]:
              country = row[1].split('»')[0]
              continue
          game_time = row[1]
          game_date = row[1].split('-')[0]     
          score = None    
          if score is not None:    
              return row[3]    
          game_data.date.append(game_date)
          game_data.time.append(game_time)
          game_data.country.append(country)
          game_data.league.append(count[1].text)
          game_data.game.append(row[2])
          game_data.score.append(score) #This should be score if available else NaN
          game_data.home_odds.append(row[4])
          game_data.draw_odds.append(row[5])
          game_data.away_odds.append(row[6])
  
  
  
      return game_data
  
  
  if __name__ == '__main__':
  
      start_url = &quot;https://www.oddsportal.com/matches/soccer/&quot;
      urls = []
      browser = webdriver.Chrome()
      results = None
      urls = get_urls(browser, start_url)
      urls.insert(0, start_url)
  
      for number, url in enumerate(urls):
          if number &gt; 0:
              browser.get(url)
          html = browser.page_source
          game_data = parse_data(html)
  
          if game_data is None:
              continue
  
          result = pd.DataFrame(game_data.__dict__)
  
          if results is None:
              results = result
          else:
              results = results.append(result, ignore_index=True)
  </code></pre>
  <p>The [score] column does not have data. How do I handle this?
  I would like to return NaN if no value and if present, return value. The above code is skipping the column altogether. How di i handle it?</p>
  <p>Since SO wants me to explain further and since I have mostly code, I would like to know ho do I build this dataframe correctly?</p>