df_image : is a pandas data frame with a column labelled 'bytes', which contains image data in bytearray format.
I display the images as follows:
[display(Image(copy.copy(BytesIO(x)).read(),width=300,height=170)) for x in df_image['bytes']]
Now I try a different method:
c = duckdb.query(
"select a.bytes \
from \
df_image a"
).df()
then,
[display(Image(copy.copy(BytesIO(x)).read(),width=300,height=170)) for x in c['bytes']]
this fails with: TypeError: a bytes-like object is required, not 'str'
I guess in BytesIO(x), x was fed in as str.
I tried
codecs.escape_decode(bytes(c.loc[0:0,'bytes'][0], "utf-16"))[0].decode("utf-16")
but the image data is corrupted.