Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
I have a simple test script as follows:
import pandas as pd
dataframe_info = pd.DataFrame(dataset.dtypes)
dataframe_copy = pd.DataFrame(dataset)
dataframe_obj = pd.DataFrame(dataset.loc[:,"Object_Value"])
I'm finding that my table (data source table from SQL Server) which contains a variety of column types, including string, integer, real, and binary, when placed into the "dataset" dataframe, converts the column types to all strings. I know that we can check a box to infer data types, but that doesn't work for my binary fields which all get converted to the string "System.Byte()".
dataframe_info shows all the correct column types, but dataframe.copy has converted all the columns to strings.
Why are the native types in the source table not reserved in the dataframe "dataset"? When I use Python odbc to read the same table into a dataframe, all the types are preserved, including binary.
Thanks in advance.
When importing with Power BI, it would reserve the original type.
As searched, it is said pd.dataframe can't read binary file correctly.
We need to find some python functions to deal with the binary type data.
As a tempory workaround, you could convert the binary type firstly in Power BI, then use python scripts.
Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Maggie:
I don't know how to attach images to a post without uploading to a URL, so I'll have to describe what I'm seeing.
I don't expect PQ to decypher my binary contents (that's why I'm writing the Python code).
Thanks,
Chris
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.