This script allows python users to utilize Clayton Thyne's Stata file for creating ccodes in country-level datasets. Allows for easy merging. Uses a modified text file of original stata code to scrape ccode numbers and country name strings.
UPDATE 2/27/2018: Added 13 additional non-uniform country strings based on NAP dataset. The changes are reflected in the clthyn.txt file
Credit for ccode/country information goes to Dr. Clayton Thyne at Kentucky. Process based on original .do file made by Thyne. See http://www.uky.edu/~clthyn2/research.htm for more information.
from replace_ccode_country import ccode_make
df = ccode_make(df, 'clthyn.txt', 'country')
ccode_make(df, file_name, c_var)
- df = your data frame
- file_name = clayton thyne's do script in modified text form
- c_var = the original country string variable name from your df