prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  US-BPA failing due to changes in data layout and timezone 
  ```shell
    File "/home/contrib/parsers/US_BPA.py", line 113, in fetch_production
      raw_data = get_data(GENERATION_URL, session=session)
    File "/home/contrib/parsers/US_BPA.py", line 25, in get_data
      df = pd.read_table(StringIO(req.text), skiprows=5)
    File "/usr/local/lib/python3.6/site-packages/pandas/io/parsers.py", line 685, in parser_f
      return _read(filepath_or_buffer, kwds)
    File "/usr/local/lib/python3.6/site-packages/pandas/io/parsers.py", line 463, in _read
      data = parser.read(nrows)
    File "/usr/local/lib/python3.6/site-packages/pandas/io/parsers.py", line 1154, in read
      ret = self._engine.read(nrows)
    File "/usr/local/lib/python3.6/site-packages/pandas/io/parsers.py", line 2059, in read
      data = self._reader.read(nrows)
    File "pandas/_libs/parsers.pyx", line 881, in pandas._libs.parsers.TextReader.read
    File "pandas/_libs/parsers.pyx", line 896, in pandas._libs.parsers.TextReader._read_low_memory
    File "pandas/_libs/parsers.pyx", line 950, in pandas._libs.parsers.TextReader._read_rows
    File "pandas/_libs/parsers.pyx", line 937, in pandas._libs.parsers.TextReader._tokenize_rows
    File "pandas/_libs/parsers.pyx", line 2132, in pandas._libs.parsers.raise_parser_error
  pandas.errors.ParserError: Error tokenizing data. C error: Expected 1 fields in line 12, saw 6
  ```
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `parsers/US_BPA.py`
  Content:
  ```
  1 #!/usr/bin/env python3
  2 
  3 """Parser for the Bonneville Power Administration area of the USA."""
  4 
  5 from datetime import datetime, timedelta
  6 from io import StringIO
  7 import logging
  8 import pandas as pd
  9 import pytz
  10 import requests
  11 
  12 
  13 GENERATION_URL = 'https://transmission.bpa.gov/business/operations/Wind/baltwg.txt'
  14 
  15 GENERATION_MAPPING = {'Wind': 'wind',
  16                       'Hydro': 'hydro',
  17                       'Fossil/Biomass': 'unknown',
  18                       'Nuclear': 'nuclear'}
  19 
  20 
  21 def get_data(url, session=None):
  22     """Returns a pandas dataframe."""
  23     s=session or requests.Session()
  24     req = s.get(url)
  25     df = pd.read_table(StringIO(req.text), skiprows=5)
  26 
  27     return df
  28 
  29 
  30 def timestamp_converter(timestamp):
  31     """Turns string representation of time into an aware datetime object."""
  32 
  33     dt_naive = datetime.strptime(timestamp, '%m/%d/%Y %H:%M')
  34     western = pytz.timezone('America/Los_Angeles')
  35     dt_aware = western.localize(dt_naive)
  36 
  37     return dt_aware
  38 
  39 
  40 def data_processor(df, logger):
  41     """
  42     Takes a dataframe and drops all generation rows that are empty or more
  43     than 1 day old. Turns each row into a dictionary and removes any generation
  44     types that are unknown.
  45     Returns a list of tuples in the form (datetime, production).
  46     """
  47 
  48     df= df.dropna(thresh=2)
  49     df.columns = df.columns.str.strip()
  50 
  51     # 5min data for the last 24 hours.
  52     df = df.tail(288)
  53     df['Date/Time'] = df['Date/Time'].map(timestamp_converter)
  54 
  55     known_keys = GENERATION_MAPPING.keys() | {'Date/Time', 'Load'}
  56     column_headers = set(df.columns)
  57 
  58     unknown_keys = column_headers - known_keys
  59 
  60     for k in unknown_keys:
  61         logger.warning('New data {} seen in US-BPA data source'.format(k),
  62                         extra={'key': 'US-BPA'})
  63 
  64     keys_to_remove = unknown_keys | {'Load'}
  65 
  66     processed_data = []
  67     for index, row in df.iterrows():
  68         production = row.to_dict()
  69 
  70         dt = production.pop('Date/Time')
  71         dt = dt.to_pydatetime()
  72         mapped_production = {GENERATION_MAPPING[k]:v for k,v in production.items()
  73                              if k not in keys_to_remove}
  74 
  75         processed_data.append((dt, mapped_production))
  76 
  77     return processed_data
  78 
  79 
  80 def fetch_production(zone_key='US-BPA', session=None, target_datetime=None, logger=logging.getLogger(__name__)):
  81     """
  82     Requests the last known production mix (in MW) of a given zone
  83     Arguments:
  84     zone_key (optional) -- used in case a parser is able to fetch multiple zones
  85     session (optional) -- request session passed in order to re-use an existing session
  86     Return:
  87     A dictionary in the form:
  88     {
  89       'zoneKey': 'FR',
  90       'datetime': '2017-01-01T00:00:00Z',
  91       'production': {
  92           'biomass': 0.0,
  93           'coal': 0.0,
  94           'gas': 0.0,
  95           'hydro': 0.0,
  96           'nuclear': null,
  97           'oil': 0.0,
  98           'solar': 0.0,
  99           'wind': 0.0,
  100           'geothermal': 0.0,
  101           'unknown': 0.0
  102       },
  103       'storage': {
  104           'hydro': -10.0,
  105       },
  106       'source': 'mysource.com'
  107     }
  108     """
  109 
  110     if target_datetime:
  111         raise NotImplementedError('This parser is not yet able to parse past dates')
  112 
  113     raw_data = get_data(GENERATION_URL, session=session)
  114     processed_data = data_processor(raw_data, logger)
  115 
  116     data = []
  117     for item in processed_data:
  118         datapoint = {'zoneKey': zone_key,
  119                      'datetime': item[0],
  120                      'production': item[1],
  121                      'storage': {},
  122                      'source': 'bpa.gov'}
  123 
  124         data.append(datapoint)
  125 
  126     return data
  127 
  128 
  129 if __name__ == '__main__':
  130     print('fetch_production() ->')
  131     print(fetch_production())
  132
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/parsers/US_BPA.py b/parsers/US_BPA.py
  --- a/parsers/US_BPA.py
  +++ b/parsers/US_BPA.py
  @@ -2,11 +2,11 @@
   
   """Parser for the Bonneville Power Administration area of the USA."""
   
  -from datetime import datetime, timedelta
  +
   from io import StringIO
  +import arrow
   import logging
   import pandas as pd
  -import pytz
   import requests
   
   
  @@ -20,19 +20,18 @@
   
   def get_data(url, session=None):
       """Returns a pandas dataframe."""
  -    s=session or requests.Session()
  +    s = session or requests.Session()
       req = s.get(url)
  -    df = pd.read_table(StringIO(req.text), skiprows=5)
  +    df = pd.read_table(StringIO(req.text), skiprows=11)
   
       return df
   
   
   def timestamp_converter(timestamp):
  -    """Turns string representation of time into an aware datetime object."""
  +    """Turns a timestamp str into an aware datetime object."""
   
  -    dt_naive = datetime.strptime(timestamp, '%m/%d/%Y %H:%M')
  -    western = pytz.timezone('America/Los_Angeles')
  -    dt_aware = western.localize(dt_naive)
  +    arr_dt_naive = arrow.get(timestamp, 'MM/DD/YYYY HH:mm')
  +    dt_aware = arr_dt_naive.replace(tzinfo='America/Los_Angeles').datetime
   
       return dt_aware
   
  @@ -45,7 +44,7 @@
       Returns a list of tuples in the form (datetime, production).
       """
   
  -    df= df.dropna(thresh=2)
  +    df = df.dropna(thresh=2)
       df.columns = df.columns.str.strip()
   
       # 5min data for the last 24 hours.
  @@ -59,7 +58,7 @@
   
       for k in unknown_keys:
           logger.warning('New data {} seen in US-BPA data source'.format(k),
  -                        extra={'key': 'US-BPA'})
  +                       extra={'key': 'US-BPA'})
   
       keys_to_remove = unknown_keys | {'Load'}
   
  @@ -69,7 +68,7 @@
   
           dt = production.pop('Date/Time')
           dt = dt.to_pydatetime()
  -        mapped_production = {GENERATION_MAPPING[k]:v for k,v in production.items()
  +        mapped_production = {GENERATION_MAPPING[k]: v for k, v in production.items()
                                if k not in keys_to_remove}
   
           processed_data.append((dt, mapped_production))
  
verification_info: {"golden_diff": "diff --git a/parsers/US_BPA.py b/parsers/US_BPA.py\n--- a/parsers/US_BPA.py\n+++ b/parsers/US_BPA.py\n@@ -2,11 +2,11 @@\n \n \"\"\"Parser for the Bonneville Power Administration area of the USA.\"\"\"\n \n-from datetime import datetime, timedelta\n+\n from io import StringIO\n+import arrow\n import logging\n import pandas as pd\n-import pytz\n import requests\n \n \n@@ -20,19 +20,18 @@\n \n def get_data(url, session=None):\n     \"\"\"Returns a pandas dataframe.\"\"\"\n-    s=session or requests.Session()\n+    s = session or requests.Session()\n     req = s.get(url)\n-    df = pd.read_table(StringIO(req.text), skiprows=5)\n+    df = pd.read_table(StringIO(req.text), skiprows=11)\n \n     return df\n \n \n def timestamp_converter(timestamp):\n-    \"\"\"Turns string representation of time into an aware datetime object.\"\"\"\n+    \"\"\"Turns a timestamp str into an aware datetime object.\"\"\"\n \n-    dt_naive = datetime.strptime(timestamp, '%m/%d/%Y %H:%M')\n-    western = pytz.timezone('America/Los_Angeles')\n-    dt_aware = western.localize(dt_naive)\n+    arr_dt_naive = arrow.get(timestamp, 'MM/DD/YYYY HH:mm')\n+    dt_aware = arr_dt_naive.replace(tzinfo='America/Los_Angeles').datetime\n \n     return dt_aware\n \n@@ -45,7 +44,7 @@\n     Returns a list of tuples in the form (datetime, production).\n     \"\"\"\n \n-    df= df.dropna(thresh=2)\n+    df = df.dropna(thresh=2)\n     df.columns = df.columns.str.strip()\n \n     # 5min data for the last 24 hours.\n@@ -59,7 +58,7 @@\n \n     for k in unknown_keys:\n         logger.warning('New data {} seen in US-BPA data source'.format(k),\n-                        extra={'key': 'US-BPA'})\n+                       extra={'key': 'US-BPA'})\n \n     keys_to_remove = unknown_keys | {'Load'}\n \n@@ -69,7 +68,7 @@\n \n         dt = production.pop('Date/Time')\n         dt = dt.to_pydatetime()\n-        mapped_production = {GENERATION_MAPPING[k]:v for k,v in production.items()\n+        mapped_production = {GENERATION_MAPPING[k]: v for k, v in production.items()\n                              if k not in keys_to_remove}\n \n         processed_data.append((dt, mapped_production))\n", "issue": "US-BPA failing due to changes in data layout and timezone \n```shell\r\n  File \"/home/contrib/parsers/US_BPA.py\", line 113, in fetch_production\r\n    raw_data = get_data(GENERATION_URL, session=session)\r\n  File \"/home/contrib/parsers/US_BPA.py\", line 25, in get_data\r\n    df = pd.read_table(StringIO(req.text), skiprows=5)\r\n  File \"/usr/local/lib/python3.6/site-packages/pandas/io/parsers.py\", line 685, in parser_f\r\n    return _read(filepath_or_buffer, kwds)\r\n  File \"/usr/local/lib/python3.6/site-packages/pandas/io/parsers.py\", line 463, in _read\r\n    data = parser.read(nrows)\r\n  File \"/usr/local/lib/python3.6/site-packages/pandas/io/parsers.py\", line 1154, in read\r\n    ret = self._engine.read(nrows)\r\n  File \"/usr/local/lib/python3.6/site-packages/pandas/io/parsers.py\", line 2059, in read\r\n    data = self._reader.read(nrows)\r\n  File \"pandas/_libs/parsers.pyx\", line 881, in pandas._libs.parsers.TextReader.read\r\n  File \"pandas/_libs/parsers.pyx\", line 896, in pandas._libs.parsers.TextReader._read_low_memory\r\n  File \"pandas/_libs/parsers.pyx\", line 950, in pandas._libs.parsers.TextReader._read_rows\r\n  File \"pandas/_libs/parsers.pyx\", line 937, in pandas._libs.parsers.TextReader._tokenize_rows\r\n  File \"pandas/_libs/parsers.pyx\", line 2132, in pandas._libs.parsers.raise_parser_error\r\npandas.errors.ParserError: Error tokenizing data. C error: Expected 1 fields in line 12, saw 6\r\n```\n", "before_files": [{"content": "#!/usr/bin/env python3\n\n\"\"\"Parser for the Bonneville Power Administration area of the USA.\"\"\"\n\nfrom datetime import datetime, timedelta\nfrom io import StringIO\nimport logging\nimport pandas as pd\nimport pytz\nimport requests\n\n\nGENERATION_URL = 'https://transmission.bpa.gov/business/operations/Wind/baltwg.txt'\n\nGENERATION_MAPPING = {'Wind': 'wind',\n                      'Hydro': 'hydro',\n                      'Fossil/Biomass': 'unknown',\n                      'Nuclear': 'nuclear'}\n\n\ndef get_data(url, session=None):\n    \"\"\"Returns a pandas dataframe.\"\"\"\n    s=session or requests.Session()\n    req = s.get(url)\n    df = pd.read_table(StringIO(req.text), skiprows=5)\n\n    return df\n\n\ndef timestamp_converter(timestamp):\n    \"\"\"Turns string representation of time into an aware datetime object.\"\"\"\n\n    dt_naive = datetime.strptime(timestamp, '%m/%d/%Y %H:%M')\n    western = pytz.timezone('America/Los_Angeles')\n    dt_aware = western.localize(dt_naive)\n\n    return dt_aware\n\n\ndef data_processor(df, logger):\n    \"\"\"\n    Takes a dataframe and drops all generation rows that are empty or more\n    than 1 day old. Turns each row into a dictionary and removes any generation\n    types that are unknown.\n    Returns a list of tuples in the form (datetime, production).\n    \"\"\"\n\n    df= df.dropna(thresh=2)\n    df.columns = df.columns.str.strip()\n\n    # 5min data for the last 24 hours.\n    df = df.tail(288)\n    df['Date/Time'] = df['Date/Time'].map(timestamp_converter)\n\n    known_keys = GENERATION_MAPPING.keys() | {'Date/Time', 'Load'}\n    column_headers = set(df.columns)\n\n    unknown_keys = column_headers - known_keys\n\n    for k in unknown_keys:\n        logger.warning('New data {} seen in US-BPA data source'.format(k),\n                        extra={'key': 'US-BPA'})\n\n    keys_to_remove = unknown_keys | {'Load'}\n\n    processed_data = []\n    for index, row in df.iterrows():\n        production = row.to_dict()\n\n        dt = production.pop('Date/Time')\n        dt = dt.to_pydatetime()\n        mapped_production = {GENERATION_MAPPING[k]:v for k,v in production.items()\n                             if k not in keys_to_remove}\n\n        processed_data.append((dt, mapped_production))\n\n    return processed_data\n\n\ndef fetch_production(zone_key='US-BPA', session=None, target_datetime=None, logger=logging.getLogger(__name__)):\n    \"\"\"\n    Requests the last known production mix (in MW) of a given zone\n    Arguments:\n    zone_key (optional) -- used in case a parser is able to fetch multiple zones\n    session (optional) -- request session passed in order to re-use an existing session\n    Return:\n    A dictionary in the form:\n    {\n      'zoneKey': 'FR',\n      'datetime': '2017-01-01T00:00:00Z',\n      'production': {\n          'biomass': 0.0,\n          'coal': 0.0,\n          'gas': 0.0,\n          'hydro': 0.0,\n          'nuclear': null,\n          'oil': 0.0,\n          'solar': 0.0,\n          'wind': 0.0,\n          'geothermal': 0.0,\n          'unknown': 0.0\n      },\n      'storage': {\n          'hydro': -10.0,\n      },\n      'source': 'mysource.com'\n    }\n    \"\"\"\n\n    if target_datetime:\n        raise NotImplementedError('This parser is not yet able to parse past dates')\n\n    raw_data = get_data(GENERATION_URL, session=session)\n    processed_data = data_processor(raw_data, logger)\n\n    data = []\n    for item in processed_data:\n        datapoint = {'zoneKey': zone_key,\n                     'datetime': item[0],\n                     'production': item[1],\n                     'storage': {},\n                     'source': 'bpa.gov'}\n\n        data.append(datapoint)\n\n    return data\n\n\nif __name__ == '__main__':\n    print('fetch_production() ->')\n    print(fetch_production())\n", "path": "parsers/US_BPA.py"}], "after_files": [{"content": "#!/usr/bin/env python3\n\n\"\"\"Parser for the Bonneville Power Administration area of the USA.\"\"\"\n\n\nfrom io import StringIO\nimport arrow\nimport logging\nimport pandas as pd\nimport requests\n\n\nGENERATION_URL = 'https://transmission.bpa.gov/business/operations/Wind/baltwg.txt'\n\nGENERATION_MAPPING = {'Wind': 'wind',\n                      'Hydro': 'hydro',\n                      'Fossil/Biomass': 'unknown',\n                      'Nuclear': 'nuclear'}\n\n\ndef get_data(url, session=None):\n    \"\"\"Returns a pandas dataframe.\"\"\"\n    s = session or requests.Session()\n    req = s.get(url)\n    df = pd.read_table(StringIO(req.text), skiprows=11)\n\n    return df\n\n\ndef timestamp_converter(timestamp):\n    \"\"\"Turns a timestamp str into an aware datetime object.\"\"\"\n\n    arr_dt_naive = arrow.get(timestamp, 'MM/DD/YYYY HH:mm')\n    dt_aware = arr_dt_naive.replace(tzinfo='America/Los_Angeles').datetime\n\n    return dt_aware\n\n\ndef data_processor(df, logger):\n    \"\"\"\n    Takes a dataframe and drops all generation rows that are empty or more\n    than 1 day old. Turns each row into a dictionary and removes any generation\n    types that are unknown.\n    Returns a list of tuples in the form (datetime, production).\n    \"\"\"\n\n    df = df.dropna(thresh=2)\n    df.columns = df.columns.str.strip()\n\n    # 5min data for the last 24 hours.\n    df = df.tail(288)\n    df['Date/Time'] = df['Date/Time'].map(timestamp_converter)\n\n    known_keys = GENERATION_MAPPING.keys() | {'Date/Time', 'Load'}\n    column_headers = set(df.columns)\n\n    unknown_keys = column_headers - known_keys\n\n    for k in unknown_keys:\n        logger.warning('New data {} seen in US-BPA data source'.format(k),\n                       extra={'key': 'US-BPA'})\n\n    keys_to_remove = unknown_keys | {'Load'}\n\n    processed_data = []\n    for index, row in df.iterrows():\n        production = row.to_dict()\n\n        dt = production.pop('Date/Time')\n        dt = dt.to_pydatetime()\n        mapped_production = {GENERATION_MAPPING[k]: v for k, v in production.items()\n                             if k not in keys_to_remove}\n\n        processed_data.append((dt, mapped_production))\n\n    return processed_data\n\n\ndef fetch_production(zone_key='US-BPA', session=None, target_datetime=None, logger=logging.getLogger(__name__)):\n    \"\"\"\n    Requests the last known production mix (in MW) of a given zone\n    Arguments:\n    zone_key (optional) -- used in case a parser is able to fetch multiple zones\n    session (optional) -- request session passed in order to re-use an existing session\n    Return:\n    A dictionary in the form:\n    {\n      'zoneKey': 'FR',\n      'datetime': '2017-01-01T00:00:00Z',\n      'production': {\n          'biomass': 0.0,\n          'coal': 0.0,\n          'gas': 0.0,\n          'hydro': 0.0,\n          'nuclear': null,\n          'oil': 0.0,\n          'solar': 0.0,\n          'wind': 0.0,\n          'geothermal': 0.0,\n          'unknown': 0.0\n      },\n      'storage': {\n          'hydro': -10.0,\n      },\n      'source': 'mysource.com'\n    }\n    \"\"\"\n\n    if target_datetime:\n        raise NotImplementedError('This parser is not yet able to parse past dates')\n\n    raw_data = get_data(GENERATION_URL, session=session)\n    processed_data = data_processor(raw_data, logger)\n\n    data = []\n    for item in processed_data:\n        datapoint = {'zoneKey': zone_key,\n                     'datetime': item[0],\n                     'production': item[1],\n                     'storage': {},\n                     'source': 'bpa.gov'}\n\n        data.append(datapoint)\n\n    return data\n\n\nif __name__ == '__main__':\n    print('fetch_production() ->')\n    print(fetch_production())\n", "path": "parsers/US_BPA.py"}]}