IBM / analyze-customer-data-spark-pixiedust

An introductory IBM Developer Code Pattern on how to use PixieDust to visualize customer data
https://developer.ibm.com/patterns/analyze-historical-shopping-data-spark-pixiedust-jupyter-notebook/
Apache License 2.0
14 stars 22 forks source link

Cannot view data with mapbox #4

Open Ali-Parandeh opened 5 years ago

Ali-Parandeh commented 5 years ago

When trying to view customer density by location with a map using mapbox (and my own token), this error is given.

the JSON object must be str, bytes or bytearray, not 'int'

Need to include further code in the notebook to format data appropriately

stevemar commented 5 years ago

I was able to recreate this error. Oddly enough even after converting AGE/CUST_ID/POSTALCODE (the only integer columns) to strings, I still got the same error.

The good part is that the google maps viewer works without having to change the data.

Ali-Parandeh commented 5 years ago

I don't think the problem is with our data. I think the problem is with the JSON content the API is sending back.

The JSON response object received from the API in the example has integers in it (1 instead of "1"). Mapbox Geocoding API Docs

Maybe PixieDust's JSON handler is not equipped to deal with ints in the JSON object retrieved?

See here: Pixiedust json Handlers Pixiedust Mapbox Renderer

stevemar commented 5 years ago

@vabarbosa i think you're more familiar with pixiedust than I am, can you look at this issue?

Ali-Parandeh commented 5 years ago

I don't understand the pixidust codebase too much or the API response object to be able to rectify the issue. Do you know anyone in IBM who have worked on Pixiedust?

stevemar commented 5 years ago

@Ali-Parandeh i'm hoping @vabarbosa or @DTAIEB can confirm if this is a bug in pixiedust or not.

vabarbosa commented 5 years ago

@Ali-Parandeh @stevemar the PixieDust MapBox renderer does is trying to convert the DataFrame data to GeoJSON. for that, it requires/expects the selected Key fields to be a columns that represents latitude & longitude values. see the MapBox section of this PixieDust article: https://medium.com/codait/mapping-for-data-science-with-pixiedust-and-mapbox-b5aa1d9532b9

in this case, the Key field (STATE) provided does not correspond to a latitude value and the conversion is failing. the error message is misleading and could definitely be improved.

PixieDust's MapBox renderer works only with data that have columns containing latitude & longitude values. this is a current limitation. for data with State/Country names, you should use the Google Map renderer instead.