How are sub-Saharan African economies doing? It depends on where you look, says the International Money Fund in its latest survey of the continent.

Regional growth will slow to 1.4 percent this year, the most sluggish pace for two decades.

Things look grim in Nigeria, which is mired in recession.

But Ivory Coast, a short flight away, is thundering along at a growth rate of 8 percent.

Similar contrasts are found across the continent. Better to talk of two Africas, says the IMF, moving at different speeds.

The big divider is resources. As commodity prices have slumped, so too have the fortunes of big exporters. As a group, resource-rich countries will grow on average by 0.3 percent of GDP, says the IMF.

Take oil-rich Angola, once the fastest-growing country on the continent: It will not grow at all this year, and is wrestling with inflation of 38 percent. Commodity-exporting countries saw the value of their exports to China almost halve in 2015. Public debt is rising sharply. Exchange rates are falling. Private consumption has collapsed.

Things look very different in countries which are less resource-dependent. They will grow at 5.5 percent this year. They have been helped, of course, by falling oil prices, which makes their imports cheaper. But they are stronger in other ways too. In east Africa, for example, a wave of public investment in infrastructure has boosted demand.

Governments cannot set commodity prices. Nor can they stop drought, which has hit agriculture in countries such as Ethiopia and Malawi. But their decisions do make a difference. Nigeria's disastrous attempt to prop up its exchange rate hurt far more than it helped. Investors in Mozambique were unimpressed when the country revealed hidden debts in April. Growth in South Africa has slowed to almost zero amid political wrangles and an energy crisis. Now is the time to get the policies right, urges the IMF.

The numbers should be read with a pinch of salt: GDP figures are only ever a best guess, and Africa's large informal economy makes the calculation even harder. Talk to traders in Uganda, for instance, and you will hear a story very different to the IMF's forecast of 5 percent growth. The overall lesson, though, is clear. If you rely on commodities, diversify or face consequences. That is easier said than done. Look to east African countries, hailed for their innovations in mobile banking, who are suddenly now touting a fresh source of riches: oil and gas.

Copyright 2013 The Economist Newspaper Limited, London. All Rights Reserved. Reprinted with permission.