I am working on a base-datatable with a VARBINARY variable. Now I want to read the table via SQLAlchemy into a pandas dataframe. Going the usual way
df = pandas.read_sql_query("select key from xxx", engine)
I get an uninterpretable memoryview as data type. I can convert this via lambda function
df.key.apply(lambda x: x.tobytes().hex())
into the desired readable format. But I would like to know if the casting can also be placed directly into the pandas.read_sql_query()-statement:
via numpy dtypes or maybe
directly into the SQL-query
Many greetings and best thanks
I am not sure if this will help you but, thanks to @JGFMK response, I was able to come up with something similar on my program:
Mappedto convert the value that has aDATA_TYPEfrom the SQL Server.decodemethod on the property, according to the collation my SQL Server is using, going toProperties > Generalon my Database.This was the result:
So, in your case you can try using
decodealongsidereplaceon the specific data on your dataframe that hasVARBINARYtype.Example:
I believe something like that would work.