{"action":"created","issue":{"url":"https://api.github.com/repos/python-visualization/folium/issues/790","repository_url":"https://api.github.com/repos/python-visualization/folium","labels_url":"https://api.github.com/repos/python-visualization/folium/issues/790/labels{/name}","comments_url":"https://api.github.com/repos/python-visualization/folium/issues/790/comments","events_url":"https://api.github.com/repos/python-visualization/folium/issues/790/events","html_url":"https://github.com/python-visualization/folium/issues/790","id":279987945,"number":790,"title":"Bug when trying to set threshold scale in choropleth","user":{"login":"marlanbar","id":4984019,"avatar_url":"https://avatars1.githubusercontent.com/u/4984019?v=4","gravatar_id":"","url":"https://api.github.com/users/marlanbar","html_url":"https://github.com/marlanbar","followers_url":"https://api.github.com/users/marlanbar/followers","following_url":"https://api.github.com/users/marlanbar/following{/other_user}","gists_url":"https://api.github.com/users/marlanbar/gists{/gist_id}","starred_url":"https://api.github.com/users/marlanbar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marlanbar/subscriptions","organizations_url":"https://api.github.com/users/marlanbar/orgs","repos_url":"https://api.github.com/users/marlanbar/repos","events_url":"https://api.github.com/users/marlanbar/events{/privacy}","received_events_url":"https://api.github.com/users/marlanbar/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-12-07T03:26:31Z","updated_at":"2017-12-10T12:21:02Z","closed_at":null,"author_association":"NONE","body":"I tried to set a threshold scale in choropleth using qcut.\r\n```python\r\n_, threshold_scale = pd.qcut(home_zips[\"count\"], q=8, retbins=True)\r\nm.choropleth(geo_data=\"./data/zip_code.geojson\",\r\n             data=home_zips,\r\n             columns=['ZCTA5CE10',\"count\"],\r\n             fill_color='YlOrRd',\r\n             key_on='feature.properties.ZCTA5CE10',\r\n             fill_opacity=0.9,\r\n             line_opacity=0.5,\r\n             legend_name='Top US Banks Clients by Home Zip',\r\n             threshold_scale=threshold_scale)\r\n```\r\n#### Problem description\r\nWhatever threshold I am trying to use, this error arises:\r\n\r\n```\r\n---------------------------------------------------------------------------\r\nValueError                                Traceback (most recent call last)\r\n<ipython-input-75-0ea58867fab5> in <module>()\r\n      9              line_opacity=0.5,\r\n     10              legend_name='Top US Banks Clients by Home Zip',\r\n---> 11              threshold_scale=threshold_scale)\r\n     12 \r\n     13 m.save(outfile='datamap_TopBanks.html')\r\n\r\n/home/mlangberg/venv/local/lib/python2.7/site-packages/folium/folium.pyc in choropleth(self, geo_data, data, columns, key_on, threshold_scale, fill_color, fill_opacity, line_color, line_weight, line_opacity, name, legend_name, topojson, reset, smooth_factor, highlight)\r\n    241 \r\n    242         \"\"\"\r\n--> 243         if threshold_scale and len(threshold_scale) > 6:\r\n    244             raise ValueError\r\n    245         if data is not None and not color_brewer(fill_color):\r\n\r\nValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()\r\n```\r\n\r\n#### Expected Output\r\nI expect the choropleth map with the correct threshold assigned.\r\n\r\n#### Output of ``folium.__version__``\r\nu'0.5.0'"},"comment":{"url":"https://api.github.com/repos/python-visualization/folium/issues/comments/350544442","html_url":"https://github.com/python-visualization/folium/issues/790#issuecomment-350544442","issue_url":"https://api.github.com/repos/python-visualization/folium/issues/790","id":350544442,"user":{"login":"Conengmo","id":33519926,"avatar_url":"https://avatars1.githubusercontent.com/u/33519926?v=4","gravatar_id":"","url":"https://api.github.com/users/Conengmo","html_url":"https://github.com/Conengmo","followers_url":"https://api.github.com/users/Conengmo/followers","following_url":"https://api.github.com/users/Conengmo/following{/other_user}","gists_url":"https://api.github.com/users/Conengmo/gists{/gist_id}","starred_url":"https://api.github.com/users/Conengmo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Conengmo/subscriptions","organizations_url":"https://api.github.com/users/Conengmo/orgs","repos_url":"https://api.github.com/users/Conengmo/repos","events_url":"https://api.github.com/users/Conengmo/events{/privacy}","received_events_url":"https://api.github.com/users/Conengmo/received_events","type":"User","site_admin":false},"created_at":"2017-12-10T12:21:02Z","updated_at":"2017-12-10T12:21:02Z","author_association":"CONTRIBUTOR","body":"The `pd.qcut` method returns a Numpy array as second variable, so in your example `threshold_scale` is a Numpy array, while Folium expects a list. So a quick fix for you would be to change the array into a list before putting it in the chloropleth method.\r\n\r\n`threshold_scale = list(threshold_scale)`\r\n\r\nA fix for Folium could be to not check if `threshold_scale` is set using `if threshold_scale`, but use `if threshold_scale is not None` instead."}}
{"actor":{"display_login":"Conengmo"}}