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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
Penguin236
Frequent Visitor

Python Viz table not working

I'm trying to plot a dataframe as a matplotlib table in a Python visual. I tested the code in Jupyter, and it works fine, but the same code in PowerBI gives a KeyError. The error seems to be coming from this part of the script:

 

the_table = plt.table(cellText=common_df,
colColours=ccolors,
colLabels=column_headers,
loc='center')

 

This exact same code works fine with a simpler dataframe, but when I plug in my actual one, I get a KeyError: 0. Any ideas on why this might be happening, especially given that it works fine in Jupyter?

1 REPLY 1
amitchandak
Super User
Super User

@Penguin236 , very difficult to tell with this info.

But in power bi you have to drag column on python visual and you can only use those

 

Check my video on how I created those visual

https://www.youtube.com/watch?v=rX3-G8u5fwc

 

can you share the python script including comments in power bi

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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.

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.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.