Skip to content

Commit

Permalink
Fix dtype when reading data from json
Browse files Browse the repository at this point in the history
- fix e.g. reading model '1' and '1.0' as float (leading to duplicate error)
  • Loading branch information
zikolach committed Dec 11, 2019
1 parent 7d792c4 commit cf4d398
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pyam/iiasa.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,9 @@ def query(self, **kwargs):
r = requests.post(url, headers=headers, data=data)
_check_response(r)
# refactor returned json object to be castable to an IamDataFrame
df = pd.read_json(r.content, orient='records')
dtype = dict(model=str, scenario=str, variable=str, unit=str,
region=str, year=int, value=float, version=int)
df = pd.read_json(r.content, orient='records', dtype=dtype)
logger.debug('Response size is {0} bytes, '
'{1} records'.format(len(r.content), len(df)))
columns = ['model', 'scenario', 'variable', 'unit',
Expand Down

0 comments on commit cf4d398

Please sign in to comment.