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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Crating a Python Visual using custom packages- Type Error

Hi all,

 

I have a script that I am using to create a radar plot using the custom package, soccerplots. The script works in jupyter sucessfully however when I try to replicate in Power BI I get the following error:

Jordan_H_1-1633916384091.png

Here is the script I am running in Power BI:

 

# dataset = pandas.DataFrame(Player, Gls, Sh, SoT, SoT%, Sh/90, SoT/90, G/Sh, G/SoT, Dist, xG, npxG, npxG/Sh, G-xG, np:G-xG)
# dataset = dataset.drop_duplicates()

# Paste or type your script code here:
import pandas as pd
import matplotlib.pyplot as plt
from soccerplots.radar_chart import Radar
import numpy as np

df= dataset
df= df[(df['Player']=='Tammy Abraham') | (df['Player']=='Timo Werner')].reset_index()

#parameters
params=list(df.columns)
params= params[1:]

#add ranges to list of tuple pairs
ranges = []
a_values = []
b_values = []
for x in params:
a = min(df[params][x])
a = a - (a*.25)
 
b = max(df[params][x])
b = b + (b*.25)
 
ranges.append((a,b))
 
for x in range(len(df['Player'])):
if df['Player'][x]=='Tammy Abraham':
a_values=df.iloc[x].values.tolist()
if df['Player'][x]=='Timo Werner':
b_values=df.iloc[x].values.tolist()
a_values=a_values[0:]
b_values=b_values[0:]
values=[a_values,b_values]

#title
title=dict(
title_name='Tammy Abraham',
title_color= 'red',
subtitle_name= 'Chelsea',
subtitle_color = 'red',
title_name_2='Timo Werner',
title_color_2= 'blue',
subtitle_name_2= 'Chelsea',
subtitle_color_2 = 'blue',
title_fontsize= 18,
subtitle_fontsize=15
)

endnote= '@jordanh-49 \ndata via FBREF / Statsbomb'

radar= Radar()
fig,ax= radar.plot_radar(ranges=ranges,params=params,values=values,
radar_color=['red','blue'],
alphas=[.75,.6],title=title, endnote=endnote,
compare=True)


1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

Currently you won't be able to use Python scripts in reports created with Enhanced Metadata feature enabled. Existing reports will continue to work. For more information check out Using enhanced dataset metadata (preview).

View solution in original post

2 REPLIES 2
V-lianl-msft
Community Support
Community Support

Currently you won't be able to use Python scripts in reports created with Enhanced Metadata feature enabled. Existing reports will continue to work. For more information check out Using enhanced dataset metadata (preview).

amitchandak
Super User
Super User

@Anonymous , You need to check what you getting in a. Implicit type conversion is failing.

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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.