Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
I have a simple dataset that looks like this:
year votes 1999 100 2000 150 2001 200
Trying to plot a simple line chart like this:
import matplotlib.pyplot as plt fig, ax = plt.subplots() ax.plot(dataset.year, dataset.votes) ax.set_xlim(1998, 2002) ax.set_ylim(90, 210) plt.show()
Gives me this result (i.e. nothing is plotted but Python/Power BI give me no errors).
Specifying the same data in lists and then plot them like this works:
import matplotlib.pyplot as plt fig, ax = plt.subplots() year_array= [1999,2000,2001] votes_array = [100,150,200] ax.plot(year_array, votes_array) ax.set_xlim(1998, 2002) ax.set_ylim(90, 210) plt.show()
Result:
Am I doing something wrong? The data is formatted as Numbers so the problem is not that. I am using Python 3.6.5 Anaconda distribution and Power BI 2.61.5192.601 64-bit (August 2018) on a Windows 10 machine.
Solved! Go to Solution.
My colleague found what the problem was. The values were summed when dragged in to the value field, i chose "Don't Summarize" and now it works like a charm.
My colleague found what the problem was. The values were summed when dragged in to the value field, i chose "Don't Summarize" and now it works like a charm.
Hi @Anonymous,
Based on my test, When I used the code as below. It worked well as well. Did you add the both columns to the Python visual and enter the code?
import matplotlib.pyplot as plt fig, ax = plt.subplots() ax.plot(dataset.year, dataset.votes) ax.set_xlim(1998, 2002) ax.set_ylim(90, 210) plt.show()
Regards,
Frank
Yes I did, i reckon I would have gotten `KeyError` otherwise and I got no error now. I will try on a collegaues computer and also try uninstalling and installing Power BI otherwise. Python seems to working fine outside of Power BI Python visuals so I assume there is something wrong with Power BI.
User | Count |
---|---|
102 | |
91 | |
87 | |
79 | |
71 |
User | Count |
---|---|
113 | |
105 | |
101 | |
75 | |
64 |