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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
moltra
Helper IV
Helper IV

Custom Python Visulizations dataset error

I am trying to create a custom Python Power BI Visualization.   The actual data is a direct query from a SQL Database.

The fields I want in the visualization are in the Values section of the visualization fields

 

Here is the what the data table looks like.

 

WeekReading1Reading2Reading3Reading4Reading5
12/20/2019 0:0068.86    
1/6/2020 0:0073.35    
1/13/2020 0:0077.4    
1/20/2020 0:0078.57    
3/2/2020 0:0023.29    
3/9/2020 0:0020.35    
3/16/2020 0:0022.28    
3/23/2020 0:0026.61    
5/11/2020 0:0029.38    
5/18/2020 0:0021.275.693.5235.420.02
5/25/2020 0:0014.4481.293.599.9122.51
6/1/2020 0:0014.9384.213.1841.6331.06
6/8/2020 0:004.0187.283.2139.5830.17
6/15/2020 0:0023.6888.183.4239.3527.46
6/22/2020 0:0024.6287.613.345.3931.4
6/29/2020 0:0022.884.313.1825.5719.08

 

When I start a custom Python Visualization this is what Power BI generates.

# dataset = pandas.DataFrame(Week, Reading1, Reading2, Reading3, Reading4, Reading5)

 

If I try  the following:

df.DateFrame(Week, Reading1, Reading2, Reading3, Reading4, Reading5)

It throws an error of "name Week is not defined.

 

df = pandas.DataFrame('Week','Reading1','Reading2','Reading3','Reading4','Reading5')

I get "TypeError: __init__() takes from 1 to 6 positional arguments but 7 were given"

 

df = pandas.DataFrame("Week","Reading1","Reading2","Reading3","Reading4","Reading5")

I get "TypeError: __init__() takes from 1 to 6 positional arguments but 7 were given"

 

Any help or guidance would be greatly appreaciated.

 

1 REPLY 1
v-xuding-msft
Community Support
Community Support

Hi @moltra ,

 

I think maybe you miss the definition of variable. Please reference the document to check it.

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html

 

And for the specific Python script, you could ask for help from the community: https://stackoverflow.com/questions/tagged/python

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.