Forum Discussion

Swagtika_Kumari's avatar
Swagtika_Kumari
New Member
3 years ago
Solved

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.
  • Anonymous's avatar
    Anonymous
    3 years ago

    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.

1 Reply

  • Anonymous's avatar
    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.