Maintaining label encoding across different files in pandas
The LabelEncoder like all other Sklearn-Transformers has three certain methods:

fit(): Creates the labels given some input data
transform(): Transforms data to the labels of the encoder instance. It must have called fit() before or will throw an error
fit_transform(): That's a convenience-method that will create the labels and transform the data directly.

I'm guessing you are calling fit_transform everywhere. To fix this, just call the fit-method once (on a superset of all your data because it will throw an error if it encounters a label that was not present in the data you called fit on) and than use the transform method.
I know how to use scikit-learn and pandas to encode my categorical data. I've been using the category codes in pandas for now which I later will transform into an OneHot encoded format for ML.
My issues is that I need to create a pre-processing pipeline for multiple files with the same data format. I've discovered that using the pandas category codes encoding is not consistent, even if the categories (strings) in the data are identical across multiple files.
Is there a way to do this encoding lexicographically so that it's done the same way across all files or is there any specific method that can be used which would result in the same encoding when applied on multiple files?