prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Taiwan TW.py parser fails
  Help wanted! :)
  Taiwan isn't showing any data at the moment and the parser has to be fixed.
  
  This is the error message for TW.py of the logger:
  'DataFrame' object has no attribute 'convert_objects'
  
  I get this warning running the parser locally (probably with older versions of the libraries):
  ```
  Python36-32/TW.py", line 32
      objData = objData.convert_objects(convert_numeric=True)
  FutureWarning: convert_objects is deprecated.  To re-infer data dtypes for object columns, use DataFrame.infer_objects()
  For all other conversions use the data-type specific converters pd.to_datetime, pd.to_timedelta and pd.to_numeric.
  
  ```
  But I still recieve an output:
  
  ```
  {'zoneKey': 'TW', 'datetime': datetime.datetime(2019, 10, 4, 16, 0, tzinfo=tzfile('ROC')), 'production': {'coal': 9743.199999999999, 'gas': 15124.899999999998, 'oil': 681.4, 'hydro': 726.0, 'nuclear': 3833.7000000000003, 'solar': 576.2239999999999, 'wind': 18.900000000000006, 'unknown': 1435.9}, 'capacity': {'coal': 13097.2, 'gas': 16866.4, 'oil': 2572.1, 'hydro': 2091.4999999999995, 'hydro storage': 2602.0, 'nuclear': 3872.0, 'solar': 3144.4, 'wind': 710.9999999999999, 'unknown': 623.2}, 'storage': {'hydro': -622.3}, 'source': 'taipower.com.tw'}
  ```
  
  </issue>
  <code>
  [start of parsers/TW.py]
  1 #!/usr/bin/env python3
  2 import arrow
  3 import requests
  4 import pandas
  5 import dateutil
  6 
  7 
  8 def fetch_production(zone_key='TW', session=None, target_datetime=None, logger=None):
  9     if target_datetime:
  10         raise NotImplementedError('This parser is not yet able to parse past dates')
  11 
  12     url = 'http://www.taipower.com.tw/d006/loadGraph/loadGraph/data/genary.txt'
  13     response = requests.get(url)
  14     data = response.json()
  15 
  16     dumpDate = data['']
  17     prodData = data['aaData']
  18 
  19     tz = 'Asia/Taipei'
  20     dumpDate = arrow.get(dumpDate, 'YYYY-MM-DD HH:mm').replace(tzinfo=dateutil.tz.gettz(tz))
  21 
  22     objData = pandas.DataFrame(prodData)
  23 
  24     objData.columns = ['fueltype', 'name', 'capacity', 'output', 'percentage',
  25                        'additional']
  26 
  27     objData['fueltype'] = objData.fueltype.str.split('(').str[1]
  28     objData['fueltype'] = objData.fueltype.str.split(')').str[0]
  29     objData.drop('additional', axis=1, inplace=True)
  30     objData.drop('percentage', axis=1, inplace=True)
  31 
  32     objData = objData.convert_objects(convert_numeric=True)
  33     production = pandas.DataFrame(objData.groupby('fueltype').sum())
  34     production.columns = ['capacity', 'output']
  35 
  36     coal_capacity = production.ix['Coal'].capacity + production.ix['IPP-Coal'].capacity
  37     gas_capacity = production.ix['LNG'].capacity + production.ix['IPP-LNG'].capacity
  38     oil_capacity = production.ix['Oil'].capacity + production.ix['Diesel'].capacity
  39 
  40     coal_production = production.ix['Coal'].output + production.ix['IPP-Coal'].output
  41     gas_production = production.ix['LNG'].output + production.ix['IPP-LNG'].output
  42     oil_production = production.ix['Oil'].output + production.ix['Diesel'].output
  43 
  44     # For storage, note that load will be negative, and generation positive.
  45     # We require the opposite
  46 
  47     returndata = {
  48         'zoneKey': zone_key,
  49         'datetime': dumpDate.datetime,
  50         'production': {
  51             'coal': coal_production,
  52             'gas': gas_production,
  53             'oil': oil_production,
  54             'hydro': production.ix['Hydro'].output,
  55             'nuclear': production.ix['Nuclear'].output,
  56             'solar': production.ix['Solar'].output,
  57             'wind': production.ix['Wind'].output,
  58             'unknown': production.ix['Co-Gen'].output
  59         },
  60         'capacity': {
  61             'coal': coal_capacity,
  62             'gas': gas_capacity,
  63             'oil': oil_capacity,
  64             'hydro': production.ix['Hydro'].capacity,
  65             'hydro storage':production.ix['Pumping Gen'].capacity,
  66             'nuclear': production.ix['Nuclear'].capacity,
  67             'solar': production.ix['Solar'].capacity,
  68             'wind': production.ix['Wind'].capacity,
  69             'unknown': production.ix['Co-Gen'].capacity
  70         },
  71         'storage': {
  72             'hydro': -1 * production.ix['Pumping Load'].output - production.ix['Pumping Gen'].output
  73         },
  74         'source': 'taipower.com.tw'
  75     }
  76 
  77     return returndata
  78 
  79 
  80 if __name__ == '__main__':
  81     print(fetch_production())
  82
  [end of parsers/TW.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/parsers/TW.py b/parsers/TW.py
  --- a/parsers/TW.py
  +++ b/parsers/TW.py
  @@ -10,7 +10,8 @@
           raise NotImplementedError('This parser is not yet able to parse past dates')
   
       url = 'http://www.taipower.com.tw/d006/loadGraph/loadGraph/data/genary.txt'
  -    response = requests.get(url)
  +    s = session or requests.Session()
  +    response = s.get(url)
       data = response.json()
   
       dumpDate = data['']
  @@ -29,17 +30,18 @@
       objData.drop('additional', axis=1, inplace=True)
       objData.drop('percentage', axis=1, inplace=True)
   
  -    objData = objData.convert_objects(convert_numeric=True)
  +    objData['capacity'] = pandas.to_numeric(objData['capacity'], errors='coerce')
  +    objData['output'] = pandas.to_numeric(objData['output'], errors='coerce')
       production = pandas.DataFrame(objData.groupby('fueltype').sum())
       production.columns = ['capacity', 'output']
   
  -    coal_capacity = production.ix['Coal'].capacity + production.ix['IPP-Coal'].capacity
  -    gas_capacity = production.ix['LNG'].capacity + production.ix['IPP-LNG'].capacity
  -    oil_capacity = production.ix['Oil'].capacity + production.ix['Diesel'].capacity
  +    coal_capacity = production.loc['Coal'].capacity + production.loc['IPP-Coal'].capacity
  +    gas_capacity = production.loc['LNG'].capacity + production.loc['IPP-LNG'].capacity
  +    oil_capacity = production.loc['Oil'].capacity + production.loc['Diesel'].capacity
   
  -    coal_production = production.ix['Coal'].output + production.ix['IPP-Coal'].output
  -    gas_production = production.ix['LNG'].output + production.ix['IPP-LNG'].output
  -    oil_production = production.ix['Oil'].output + production.ix['Diesel'].output
  +    coal_production = production.loc['Coal'].output + production.loc['IPP-Coal'].output
  +    gas_production = production.loc['LNG'].output + production.loc['IPP-LNG'].output
  +    oil_production = production.loc['Oil'].output + production.loc['Diesel'].output
   
       # For storage, note that load will be negative, and generation positive.
       # We require the opposite
  @@ -51,25 +53,25 @@
               'coal': coal_production,
               'gas': gas_production,
               'oil': oil_production,
  -            'hydro': production.ix['Hydro'].output,
  -            'nuclear': production.ix['Nuclear'].output,
  -            'solar': production.ix['Solar'].output,
  -            'wind': production.ix['Wind'].output,
  -            'unknown': production.ix['Co-Gen'].output
  +            'hydro': production.loc['Hydro'].output,
  +            'nuclear': production.loc['Nuclear'].output,
  +            'solar': production.loc['Solar'].output,
  +            'wind': production.loc['Wind'].output,
  +            'unknown': production.loc['Co-Gen'].output
           },
           'capacity': {
               'coal': coal_capacity,
               'gas': gas_capacity,
               'oil': oil_capacity,
  -            'hydro': production.ix['Hydro'].capacity,
  -            'hydro storage':production.ix['Pumping Gen'].capacity,
  -            'nuclear': production.ix['Nuclear'].capacity,
  -            'solar': production.ix['Solar'].capacity,
  -            'wind': production.ix['Wind'].capacity,
  -            'unknown': production.ix['Co-Gen'].capacity
  +            'hydro': production.loc['Hydro'].capacity,
  +            'hydro storage':production.loc['Pumping Gen'].capacity,
  +            'nuclear': production.loc['Nuclear'].capacity,
  +            'solar': production.loc['Solar'].capacity,
  +            'wind': production.loc['Wind'].capacity,
  +            'unknown': production.loc['Co-Gen'].capacity
           },
           'storage': {
  -            'hydro': -1 * production.ix['Pumping Load'].output - production.ix['Pumping Gen'].output
  +            'hydro': -1 * production.loc['Pumping Load'].output - production.loc['Pumping Gen'].output
           },
           'source': 'taipower.com.tw'
       }
  
verification_info: {"golden_diff": "diff --git a/parsers/TW.py b/parsers/TW.py\n--- a/parsers/TW.py\n+++ b/parsers/TW.py\n@@ -10,7 +10,8 @@\n         raise NotImplementedError('This parser is not yet able to parse past dates')\n \n     url = 'http://www.taipower.com.tw/d006/loadGraph/loadGraph/data/genary.txt'\n-    response = requests.get(url)\n+    s = session or requests.Session()\n+    response = s.get(url)\n     data = response.json()\n \n     dumpDate = data['']\n@@ -29,17 +30,18 @@\n     objData.drop('additional', axis=1, inplace=True)\n     objData.drop('percentage', axis=1, inplace=True)\n \n-    objData = objData.convert_objects(convert_numeric=True)\n+    objData['capacity'] = pandas.to_numeric(objData['capacity'], errors='coerce')\n+    objData['output'] = pandas.to_numeric(objData['output'], errors='coerce')\n     production = pandas.DataFrame(objData.groupby('fueltype').sum())\n     production.columns = ['capacity', 'output']\n \n-    coal_capacity = production.ix['Coal'].capacity + production.ix['IPP-Coal'].capacity\n-    gas_capacity = production.ix['LNG'].capacity + production.ix['IPP-LNG'].capacity\n-    oil_capacity = production.ix['Oil'].capacity + production.ix['Diesel'].capacity\n+    coal_capacity = production.loc['Coal'].capacity + production.loc['IPP-Coal'].capacity\n+    gas_capacity = production.loc['LNG'].capacity + production.loc['IPP-LNG'].capacity\n+    oil_capacity = production.loc['Oil'].capacity + production.loc['Diesel'].capacity\n \n-    coal_production = production.ix['Coal'].output + production.ix['IPP-Coal'].output\n-    gas_production = production.ix['LNG'].output + production.ix['IPP-LNG'].output\n-    oil_production = production.ix['Oil'].output + production.ix['Diesel'].output\n+    coal_production = production.loc['Coal'].output + production.loc['IPP-Coal'].output\n+    gas_production = production.loc['LNG'].output + production.loc['IPP-LNG'].output\n+    oil_production = production.loc['Oil'].output + production.loc['Diesel'].output\n \n     # For storage, note that load will be negative, and generation positive.\n     # We require the opposite\n@@ -51,25 +53,25 @@\n             'coal': coal_production,\n             'gas': gas_production,\n             'oil': oil_production,\n-            'hydro': production.ix['Hydro'].output,\n-            'nuclear': production.ix['Nuclear'].output,\n-            'solar': production.ix['Solar'].output,\n-            'wind': production.ix['Wind'].output,\n-            'unknown': production.ix['Co-Gen'].output\n+            'hydro': production.loc['Hydro'].output,\n+            'nuclear': production.loc['Nuclear'].output,\n+            'solar': production.loc['Solar'].output,\n+            'wind': production.loc['Wind'].output,\n+            'unknown': production.loc['Co-Gen'].output\n         },\n         'capacity': {\n             'coal': coal_capacity,\n             'gas': gas_capacity,\n             'oil': oil_capacity,\n-            'hydro': production.ix['Hydro'].capacity,\n-            'hydro storage':production.ix['Pumping Gen'].capacity,\n-            'nuclear': production.ix['Nuclear'].capacity,\n-            'solar': production.ix['Solar'].capacity,\n-            'wind': production.ix['Wind'].capacity,\n-            'unknown': production.ix['Co-Gen'].capacity\n+            'hydro': production.loc['Hydro'].capacity,\n+            'hydro storage':production.loc['Pumping Gen'].capacity,\n+            'nuclear': production.loc['Nuclear'].capacity,\n+            'solar': production.loc['Solar'].capacity,\n+            'wind': production.loc['Wind'].capacity,\n+            'unknown': production.loc['Co-Gen'].capacity\n         },\n         'storage': {\n-            'hydro': -1 * production.ix['Pumping Load'].output - production.ix['Pumping Gen'].output\n+            'hydro': -1 * production.loc['Pumping Load'].output - production.loc['Pumping Gen'].output\n         },\n         'source': 'taipower.com.tw'\n     }\n", "issue": "Taiwan TW.py parser fails\nHelp wanted! :)\r\nTaiwan isn't showing any data at the moment and the parser has to be fixed.\r\n\r\nThis is the error message for TW.py of the logger:\r\n'DataFrame' object has no attribute 'convert_objects'\r\n\r\nI get this warning running the parser locally (probably with older versions of the libraries):\r\n```\r\nPython36-32/TW.py\", line 32\r\n    objData = objData.convert_objects(convert_numeric=True)\r\nFutureWarning: convert_objects is deprecated.  To re-infer data dtypes for object columns, use DataFrame.infer_objects()\r\nFor all other conversions use the data-type specific converters pd.to_datetime, pd.to_timedelta and pd.to_numeric.\r\n\r\n```\r\nBut I still recieve an output:\r\n\r\n```\r\n{'zoneKey': 'TW', 'datetime': datetime.datetime(2019, 10, 4, 16, 0, tzinfo=tzfile('ROC')), 'production': {'coal': 9743.199999999999, 'gas': 15124.899999999998, 'oil': 681.4, 'hydro': 726.0, 'nuclear': 3833.7000000000003, 'solar': 576.2239999999999, 'wind': 18.900000000000006, 'unknown': 1435.9}, 'capacity': {'coal': 13097.2, 'gas': 16866.4, 'oil': 2572.1, 'hydro': 2091.4999999999995, 'hydro storage': 2602.0, 'nuclear': 3872.0, 'solar': 3144.4, 'wind': 710.9999999999999, 'unknown': 623.2}, 'storage': {'hydro': -622.3}, 'source': 'taipower.com.tw'}\r\n```\n", "before_files": [{"content": "#!/usr/bin/env python3\nimport arrow\nimport requests\nimport pandas\nimport dateutil\n\n\ndef fetch_production(zone_key='TW', session=None, target_datetime=None, logger=None):\n    if target_datetime:\n        raise NotImplementedError('This parser is not yet able to parse past dates')\n\n    url = 'http://www.taipower.com.tw/d006/loadGraph/loadGraph/data/genary.txt'\n    response = requests.get(url)\n    data = response.json()\n\n    dumpDate = data['']\n    prodData = data['aaData']\n\n    tz = 'Asia/Taipei'\n    dumpDate = arrow.get(dumpDate, 'YYYY-MM-DD HH:mm').replace(tzinfo=dateutil.tz.gettz(tz))\n\n    objData = pandas.DataFrame(prodData)\n\n    objData.columns = ['fueltype', 'name', 'capacity', 'output', 'percentage',\n                       'additional']\n\n    objData['fueltype'] = objData.fueltype.str.split('(').str[1]\n    objData['fueltype'] = objData.fueltype.str.split(')').str[0]\n    objData.drop('additional', axis=1, inplace=True)\n    objData.drop('percentage', axis=1, inplace=True)\n\n    objData = objData.convert_objects(convert_numeric=True)\n    production = pandas.DataFrame(objData.groupby('fueltype').sum())\n    production.columns = ['capacity', 'output']\n\n    coal_capacity = production.ix['Coal'].capacity + production.ix['IPP-Coal'].capacity\n    gas_capacity = production.ix['LNG'].capacity + production.ix['IPP-LNG'].capacity\n    oil_capacity = production.ix['Oil'].capacity + production.ix['Diesel'].capacity\n\n    coal_production = production.ix['Coal'].output + production.ix['IPP-Coal'].output\n    gas_production = production.ix['LNG'].output + production.ix['IPP-LNG'].output\n    oil_production = production.ix['Oil'].output + production.ix['Diesel'].output\n\n    # For storage, note that load will be negative, and generation positive.\n    # We require the opposite\n\n    returndata = {\n        'zoneKey': zone_key,\n        'datetime': dumpDate.datetime,\n        'production': {\n            'coal': coal_production,\n            'gas': gas_production,\n            'oil': oil_production,\n            'hydro': production.ix['Hydro'].output,\n            'nuclear': production.ix['Nuclear'].output,\n            'solar': production.ix['Solar'].output,\n            'wind': production.ix['Wind'].output,\n            'unknown': production.ix['Co-Gen'].output\n        },\n        'capacity': {\n            'coal': coal_capacity,\n            'gas': gas_capacity,\n            'oil': oil_capacity,\n            'hydro': production.ix['Hydro'].capacity,\n            'hydro storage':production.ix['Pumping Gen'].capacity,\n            'nuclear': production.ix['Nuclear'].capacity,\n            'solar': production.ix['Solar'].capacity,\n            'wind': production.ix['Wind'].capacity,\n            'unknown': production.ix['Co-Gen'].capacity\n        },\n        'storage': {\n            'hydro': -1 * production.ix['Pumping Load'].output - production.ix['Pumping Gen'].output\n        },\n        'source': 'taipower.com.tw'\n    }\n\n    return returndata\n\n\nif __name__ == '__main__':\n    print(fetch_production())\n", "path": "parsers/TW.py"}]}