0

I have downloaded a dataset which has countries, their codes and their GDP by year in 4 columns (5 if you include the unique row number far left). I noticed however that there are some missing codes for the country codes and was wondering if anyone could help me out and tell me how to get those codes and add them in , probably from a seperate dataset I imagine . You can see this isin the pictures I posted. Second pictures shows the missing country code data. Thanks.

. enter image description here

enter image description here

CoryAnder
  • 25
  • 2
  • East Asia is not a country but a regional description. How would you like to get its country code ? – SeaBean Jun 18 '21 at 08:12
  • Please [do not post images](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-errors-when-asking-a-question) of your data. You can include [code that creates a dataframe or the output of `print(df)`](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) (or of a few rows and columns that allow to reproduce the example) – Cimbali Jun 18 '21 at 08:19
  • Apologies for the pictures.... I will add data from now on...thanks – CoryAnder Jun 18 '21 at 10:58

1 Answers1

0

Your country codes look like ISO 3166-1, which are only defined for countries and not for the larger entities such as « East Asia » and « Western Offshoots ».

You could roll your own for these entities, see ISO country codes glossary:

User-assigned codes - If users need code elements to represent country names not included in ISO 3166-1, the series of letters [...] AAA to AAZ, QMA to QZZ, XAA to XZZ, and ZZA to ZZZ respectively, and the series of numbers 900 to 999 are available.

I think the easiest is to prefix them all with X so you know easily that they are your own codes. Then use the 2 next letters for initials:

  • East Asia: XEA
  • Western Offshoots: XWO
  • etc.
Cimbali
  • 11,012
  • 1
  • 39
  • 68
  • Brilliant thanks everyone.... absolutely makes sense now that its pointed out....East Asia is not a county... thanks for the amazing help ...stay safe – CoryAnder Jun 18 '21 at 10:57
  • You’re welcome @CoryAnder. See [this help page](https://stackoverflow.com/help/someone-answers) on the usual mechanisms to provide feedback on answers. – Cimbali Jun 18 '21 at 11:06
  • Thanks very much – CoryAnder Jun 18 '21 at 21:31