How can I transform a string variable to a categorical variable in two different datasets, keeping the same conversion?
In general, it is recommended to use the OrdinalEncoder when you are sure or know that there exists an 'ordered' relationship between the categories. For example, the grades F, B-, B, A- and A : for each of these it makes sense to have the encoding as 1,2,3,4,5 where higher the grade, higher is the weight ( in the form of the encoded category). 
In your current case, it would be better to use a OneHot encoder for the Country column before splitting into train/test datasets.
I'm building a model and I have two dataframes in Pandas. One is the training data and the other the testing data. One of the variables is the country. I was thinking about using OrdinalEncoder() to convert the country column to a categorical column. E.g.: "USA" will be 1 in the new column, "Brazil" will be 2 and so on. However, I want the same conversion for the two dataframes. If "USA" in the training data becomes 1 as a categorical column, I want that "USA" in the testing data also becomes 1.
Is that possible? How so?
Thanks in advance