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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Python Visual dataset Input as variable

Hi All,

 

Im attempting to display a compass using the pyhton visual in power BI to show the current wave direction from a sensor in the sea. 

 

It works when i define a varible in the script, but the problem arises when i want to use the data i have in one of my datasets.

 

Can the dataset be used as a variable and how ?

I have the latest angle which is what I want to use to create the graph that represents a compass.

 

any help greatly appreciated

 
4 REPLIES 4
Anonymous
Not applicable

I can try describe it better,

I have wave data for the past year. i have filtered it to only be the most recent data avaliable. It is an angle that corresponds to the direction of the waves.

 

I would like to display this angle on a compass so it is easy to understand for my client.

i have coded a graph that looks like a compass in python. 

 

I need to take the single most recent data value and use it in my python script to create the arrow (display direction).

So my question is how you take data in power BI and use it as a variable to be used for calculations in the python visual. 

Anonymous
Not applicable

Here is my code:

 

# dataset = pandas.DataFrame(Theta_p)
# dataset = dataset.drop_duplicates()
 
# Plot circle
theta = np.linspace( 0 , 2 * np.pi , 150 )

radius = 1
 
x = radius * np.cos( theta )
y = radius * np.sin( theta )
 
#recieving coordinate
rec_alpha = Theta_p

a = radius * np.cos( rec_alpha )
b = radius * np.sin( rec_alpha )
plt.scatter(a,b, c='red', s=100, label='Recieveing')

#outward coordinate
out_alpha = rec_alpha - np.pi

c = radius * np.cos( out_alpha )
d = radius * np.sin( out_alpha )
plt.scatter(c,d, color='lime', s=100, label='Outgoing')

# plot line between
x_values = [a, c]
y_values = [b, d]
plt.plot(x_values, y_values, "r-", 'bo', linestyle="--")


plt.show()
Anonymous
Not applicable

Hi @Anonymous ,

 

You could extract the data from a visual.

Please kindly refer to

Export data from a Power BI visualization - Power BI | Microsoft Docs

 

Best Regards,

ShundaSteph

 

amitchandak
Super User
Super User

@Anonymous , Not very clear. You can use the dataset as a source

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.