title: How to fix "OverflowError: Unsupported UTF-8 sequence length when encoding string"
body: <p>Getting follwoing error while converting pandas dataframe to json</p>
  
  <blockquote>
    <p>OverflowError: Unsupported UTF-8 sequence length when encoding string</p>
  </blockquote>
  
  <p>this is code to </p>
  
  <pre><code>        bytes_to_write = data.to_json(orient='records').encode()
          fs = s3fs.S3FileSystem(key=aws_access_key_id, secret=aws_secret_access_key)
          with fs.open(file, 'wb') as f:
              f.write(bytes_to_write)
  </code></pre>
  
  <p>While data which trying to convert to json contain more <code>utf-8</code> codes</p>
  
  <p>How to solve this?</p>