question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reading gdp datapackage results in ValueError: Cannot cast u'1968' for <Year>

See original GitHub issue

I just tried to use jsontableschema-pandas, and got an error from jsontableschema:

In [1]: import datapackage

In [2]: storage = datapackage.push_datapackage('http://data.okfn.org/data/core/gdp/datapackage.json', 'pandas')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-2-250f172059bb> in <module>()
----> 1 storage = datapackage.push_datapackage('http://data.okfn.org/data/core/gdp/datapackage.json', 'pandas')

/home/u1/.virtualenvs/pandas/lib/python2.7/site-packages/datapackage/pushpull.pyc in push_datapackage(descriptor, backend, **backend_options)
     74     for table in storage.buckets:
     75         if table in datamap:
---> 76             storage.write(table, datamap[table])
     77     return storage
     78 

/home/u1/.virtualenvs/pandas/lib/python2.7/site-packages/jsontableschema_pandas/storage.pyc in write(self, bucket, rows)
    136         # Prepare
    137         descriptor = self.describe(bucket)
--> 138         new_data_frame = mappers.descriptor_and_rows_to_dataframe(descriptor, rows)
    139 
    140         # Just set new DataFrame if current is empty

/home/u1/.virtualenvs/pandas/lib/python2.7/site-packages/jsontableschema_pandas/mappers.pyc in descriptor_and_rows_to_dataframe(descriptor, rows)
     31     index_rows = []
     32     jtstypes_map = {}
---> 33     for row in rows:
     34         values = []
     35         index = None

/home/u1/.virtualenvs/pandas/lib/python2.7/site-packages/datapackage/pushpull.pyc in values(schema, data)
     53         # TODO: review
     54         def values(schema, data):
---> 55             for item in data:
     56                 row = []
     57                 for field in schema['fields']:

/home/u1/.virtualenvs/pandas/lib/python2.7/site-packages/datapackage/resource.pyc in _iter_from_tabulator(self, table, schema)
    330                     except JsonTableSchemaException as exception:
    331                         message = 'Cannot cast %r for <%s>' % (value, field.name)
--> 332                         six.raise_from(ValueError(message), exception)
    333             yield keyed_row
    334 

/home/u1/.virtualenvs/pandas/lib/python2.7/site-packages/six.pyc in raise_from(value, from_value)
    716 else:
    717     def raise_from(value, from_value):
--> 718         raise value
    719 
    720 

ValueError: Cannot cast u'1968' for <Year>

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Fak3commented, Jan 16, 2017

Should the bug be moved to https://github.com/datasets/gdp repo?

0reactions
rollcommented, Jan 16, 2017
Read more comments on GitHub >

github_iconTop Results From Across the Web

In PyCaret getting error:"ValueError: Cannot cast object dtype ...
I had the same issue. It is working for me when I use python 3.7.9, but not 3.8.x or 3.9.x (as of now)....
Read more >
ValueError: Cannot cast DatetimeIndex to dtype int32 · Issue #63
In windows, receive an error using index.astype in solarposition.py line 284: from datetime import datetime t = datetime(2014,1,1,12,0,0) ...
Read more >
Gross Domestic Product - Bureau of Economic Analysis
Real gross domestic product (GDP) increased at an annual rate of 3.2 percent in the third quarter of 2022, in contrast to a...
Read more >
Gross Domestic Product: An Economy's All
Economics is no different. Economists use many abbreviations. One of the most common is GDP, which stands for gross domestic product.
Read more >
GDPNow - Federal Reserve Bank of Atlanta
GDPNow is not an official forecast of the Atlanta Fed. Rather, it is best viewed as a running estimate of real GDP growth...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found