[Python] wbgapi: resolve country name

Discussão em 'Python' iniciado por Stack, Janeiro 19, 2025.

  1. Stack

    Stack Membro Participativo

    I'd like to use the wbgapi to get a list of countries with GDP per capita for 2021, with "normal" country names.

    import wbgapi as wb

    gdppercap=wb.data.DataFrame('NY.GDP.PCAP.CD', wb.region.members('WLD'))

    # how do I pass the coder function to the rename method here, so that it returns the "WBG NAME"?
    gdppercap['YR2021'].sort_values(ascending = False).rename(index = wb.economy.coder)


    The coder function works like this:

    wb.economy.coder(['ARG', 'Korea'])

    ORIGINAL NAME WBG NAME ISO_CODE
    ARG Argentina ARG
    Korea Korea, Rep. KOR


    But I don't understand how to isolate the second column, which is what I'm after.

    Continue reading...

Compartilhe esta Página