Encoding & decoding

I don’t fully understand what the encoding parameters do in both the open() and pd.read_csv() functions.

If you have a CSV file that is encoded differently from the ‘standardUTF-8 encoding, say in cp1252, do you just had to declare the different encoding (cp1252) in the encoding parameter of the open() and pd.read_csv() functions for the data to be read & formatted correctly [in your dataframe]?

tafe = pd.csv_read('tafe_survey.csv', encoding='cp1252')

Or, do you have to change the encoding of the CSV file?

Many thanks,


Although this also works, but the natural solution is what you suggested first.

1 Like