Problem: I am getting an encoding error while trying to use pd.read_csv() to read a CSV file in an S3 location.
Below is my code:
# parameters
s3_bucket = 'my_bucket'
s3_key = 'my_key'
# create s3 client
s3_client = boto3.client('s3')
# create s3 object
obj = s3_client.get_object(Bucket=s3_bucket, Key=s3_key)
# read csv file from s3
df = pd.read_csv(obj['Body'], encoding='cp1252')
But this is the error I get: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
I don't understand why I am getting the encoding error when I am specifying the encoding to be 'cp1252'. By the way, 'cp1252' is the encoding I found for my csv file.