Closed laloune closed 9 months ago
@laloune can you provide steps to recreate this issue (before your fix) and tell me what python version you're running? Also confirm you have the latest wbgapi installed.
@tgherzog here you are: wbgapi: pip show wbgapi Name: wbgapi Version: 1.0.12
python: Python 3.12.0
Snippet to reproduces the issue:
import wbgapi as wb
data = wb.data.DataFrame("SP.POP.TOTL", time=range(2021,2022), economy='all',labels=True, skipAggs=True)
print(data)
it produces the warning: C:\Python\Lib\site-packages\wbgapi\data.py:353: FutureWarning: Setting an item of incompatible dtype is deprecated and will raise in a future error of pandas. Value 'Zimbabwe' has dtype incompatible with float64, please explicitly cast to a compatible dtype first. df2.loc[index_key, concepts[i]['value']] = row[i]['value']
Hello @tgherzog
any thoughts on this one ?
Cheers
any news about this PR ?
@laloune sorry for the delay, it's been busy here. Give me another week or so...
no problem :)
take care
@laloune sorry, I am not able to recreate the issue. What version of pandas are you running? Here's my test code: no error produced:
>>> import sys
>>> import pandas as pd
>>> import wbgapi as wb
>>> print(sys.version)
3.12.0 (v3.12.0:0fb18b02c8, Oct 2 2023, 09:45:56) [Clang 13.0.0 (clang-1300.0.29.30)]
>>> print(pd.__version__)
2.1.2
>>> print(wb.__version__)
1.0.12
>>> data = wb.data.DataFrame("SP.POP.TOTL", time=range(2021,2022), economy='all',labels=True, skipAggs=True)
No warning or error produced
This could possibility also be the consequence of an issue within the API which as since been resolved. Your issue looked specific to Zimbabwe and WBG might have fixed the issue.
@tgherzog upgrading pandas did the trick. I was still running 2.1.1
sorry for the inconvenience
the future warning was also triggered when using labels. This PR creates the columns directly after creating the frame, and set their types to str per default
(this is my very first PR of my life, sorry in advance if this is not relevant or silly)