Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Swagtika_Kumari
New Member

Python script visual undefined column

Hello,

I am trying to create a simple visual using Python script. But, when I am trying to load data in Python script, it shows "

# dataset = pandas.DataFrame(undefined, undefined.1)". It does not recognize column names.
If I am writing these column names manually, I get the following error "Python script error.< pi>KeyError: 'Sales' The above exception was the direct cause of the following exception: KeyError: 'Sales'< /pi>". I have uninstalled and installed Python 3.11.5 multiple times to rectify this error. Please help me to resolve this. Thank you.
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Swagtika_Kumari ,

Based on your description, it seems like there is an issue with the column names in your Python script. Here are some steps you can take to resolve the issue:

  1. Ensure that the column name you’re referencing in your Python script matches the column name in your Power BI data source. If there is a mismatch, you’ll get an “undefined column” error.
  2.  Check that the data type of the column in your Power BI data source matches the data type of the column in your Python script. If there is a mismatch, you may need to convert the data type in your Python script.
  3. Verify that the column you’re referencing in your Python script is present in the table you’re using as a data source for your visual.

For more details, you can read related document: Create Power BI visuals using Python in Power BI Desktop - Power BI | Microsoft Learn

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @Swagtika_Kumari ,

Based on your description, it seems like there is an issue with the column names in your Python script. Here are some steps you can take to resolve the issue:

  1. Ensure that the column name you’re referencing in your Python script matches the column name in your Power BI data source. If there is a mismatch, you’ll get an “undefined column” error.
  2.  Check that the data type of the column in your Power BI data source matches the data type of the column in your Python script. If there is a mismatch, you may need to convert the data type in your Python script.
  3. Verify that the column you’re referencing in your Python script is present in the table you’re using as a data source for your visual.

For more details, you can read related document: Create Power BI visuals using Python in Power BI Desktop - Power BI | Microsoft Learn

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors