Power BI中的Python可视化需要什么设置?是否有任何特定的matplotlib软件包版本或系统设置? [英] What setup do you need for Python Visualizations in Power BI? Any particular matplotlib package versions or system settings?

查看:226
本文介绍了Power BI中的Python可视化需要什么设置?是否有任何特定的matplotlib软件包版本或系统设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直收到错误 TypeError:from_bounds()接受4个位置参数,但给出了6个位置参数,当尝试在Power BI中插入Python可视化时。
尽管似乎Matplotlib是问题所在,但我不知道这是否是根本原因。



我的系统:

  Windows 7,64位
Power BI八月2018
Python 3.6.6.0
Matplotlib 2.2.2
熊猫0.23.4

我不能100%确定这实际上是一个版本问题,但我想不出其他任何事情,因为我使用的是已成功用于帖子



编辑1-完整的错误消息:


反馈类型:皱眉(错误)



时间戳:2018-08-15T09:58:44.0322850Z



本地时间:2018-08-15T11:58:44.0322850 + 02: 00



会话ID:85df81af-81bb-4f82-a7f4-062b315cb370



发布时间:2018年8月



产品版本:
2.61.5192.601(18.08)(x64)



错误消息:Python脚本错误。追溯(最近一次通话最近):
文件 PythonScriptWrapper.PY,第6行,在
中matplotlib.pyplot.figure(figsize =(3,75,3,52777777777778))文件 C:\ \Users\userinfo\AppData\Local\Continuum\Anaconda3\lib\site-packages\matplotlib\pyplot.py,
行548,在图中
** kwargs)文件 C:\Users\userinfo\AppData\Local\Continuum\Anaconda3\lib\site-packages\matplotlib\backend_bases.py,
行160,在new_figure_manager
图= fig_cls(* args,** kwargs)文件 C:\Users\userinfo\AppData\Local\Continuum\Anaconda3\lib\site-packages\matplotlib\ \figure.py,
行361,在 init 中,
self.bbox_inches = Bbox.from_bounds(0,0,* figsize)TypeError:from_bounds()需要4个位置参数但是给出了6个



操作系统版本:Microsoft Windows NT 6.1.7601 Service Pack 1(x64 nb-NO)



CLR版本:
4.7或更高版本[发行号= 461310]



Peak Vi虚拟内存:
4.16 GB



私有内存:398 MB



峰值工作组:532 MB



IE版本:
11.0.9600.19035



用户ID:ID号



工作簿软件包信息:1 *-nb-NO,查询组:0,fastCombine:
启用,runBackgroundAnalysis:是。



启用遥测:True



模型默认模式:导入



快照跟踪日志:C:\Users \userinfo\AppData\Local\Microsoft\Power
BI桌面\FrownSnapShot1416353677.zip



性能跟踪日志:
C :\Users\userinfo\AppData\Local\Microsoft\Power BI
Desktop\PerformanceTraces.zip



Enabled预览功能:PBI_PythonSupportEnabled



已禁用预览功能:PBI_shapeMapVisualEnabled PBI_newFromWeb
PBI_SpanishLinguisticsEnabled CustomConnectors PBI_variationUIChange
PBI_canvasTooltip s PBI_showIncrementalRefreshPolicy
PBI_compositeModels PBI_DB2DQ



禁用DirectQuery选项:PBI_DirectQuery_Unrestricted
TreatHanaAsRelationalSource



云: GlobalCloud



DPI规模:100%



支持的服务:Power BI



公式:



Section1;



共享时间序列= let
来源= Csv.Document(File.Contents( C:\data\timeseries.csv),[Delimiter =,,
Columns = 2,Encoding = 1252,QuoteStyle = QuoteStyle.None]),
#升级标题 = Table.PromoteHeaders(源,[PromoteAllScalars = true]),
#更改类型 = Table.TransformColumnTypes(#升级标题,{{日期,类型date},{ Value,Int64.Type}})在
中#更改类型;



解决方案

现在可以清楚地知道错误的来源。



在该行中(Power BI会生成o n))

  matplotlib.pyplot.figure(figsize =(5,87473572938689,6,87403100775194))

它在您的语言环境中获取尺寸(在这种情况下,使用,作为小数点)并将其传递给 figsize



figsize 接受一个以英寸为单位(宽度,高度)的元组作为输入, 5,87473572938689,6,87403100775194 被视为4个参数,而不是2个,这会导致错误。






因此要解决此问题,您可以可以显式地将 figsize (使用以为小数点的值)传递给 plt。 ,即:

  import matplotlib.pyplot as plt 
plt.figure(figsize = (5.874,6.874))
plt.plot(dataset ['Date'],dataset ['Value'])
plt.show()

或将Power BI中的区域设置更改为一个使用作为小数点而不是


的小数点

I keep getting the error TypeError: from_bounds() takes 4 positional arguments but 6 were given when trying to insert a Python Visualization in Power BI. Though it seems that Matplotlib is the problem here, I don't know if that is the root cause.

My system:

Windows 7, 64 bit
Power BI august 2018
Python 3.6.6.0
Matplotlib 2.2.2
Pandas 0.23.4

I can't be 100% sure that this is in fact a version problem, but I can't think of anything else because I'm using the same dataset that was successfully used in the post What is the best data format for a time series in a Python Visualization in Power BI?.

Data:

Date,Value
2017-01-12,1
2017-01-13,4
2017-01-14,2
2017-01-15,4
2017-01-16,2
2017-01-17,2
2017-01-18,2
2017-01-19,5
2017-01-20,5
2017-01-21,5
2017-01-22,5
2017-01-23,6
2017-01-24,3
2017-01-25,6
2017-01-26,6
2017-01-27,5
2017-01-28,8
2017-01-29,4
2017-01-30,2

Code:

import matplotlib.pyplot as plt
plt.plot(dataset['Date'], dataset['Value'])
plt.show()

Error message screenshot:

Edit 1 - The complete error message:

Feedback Type: Frown (Error)

Timestamp: 2018-08-15T09:58:44.0322850Z

Local Time: 2018-08-15T11:58:44.0322850+02:00

Session ID: 85df81af-81bb-4f82-a7f4-062b315cb370

Release: August, 2018

Product Version: 2.61.5192.601 (18.08) (x64)

Error Message: Python script error. Traceback (most recent call last): File "PythonScriptWrapper.PY", line 6, in matplotlib.pyplot.figure(figsize=(3,75,3,52777777777778)) File "C:\Users\userinfo\AppData\Local\Continuum\Anaconda3\lib\site-packages\matplotlib\pyplot.py", line 548, in figure **kwargs) File "C:\Users\userinfo\AppData\Local\Continuum\Anaconda3\lib\site-packages\matplotlib\backend_bases.py", line 160, in new_figure_manager fig = fig_cls(*args, **kwargs) File "C:\Users\userinfo\AppData\Local\Continuum\Anaconda3\lib\site-packages\matplotlib\figure.py", line 361, in init self.bbox_inches = Bbox.from_bounds(0, 0, *figsize) TypeError: from_bounds() takes 4 positional arguments but 6 were given

OS Version: Microsoft Windows NT 6.1.7601 Service Pack 1 (x64 nb-NO)

CLR Version: 4.7 or later [Release Number = 461310]

Peak Virtual Memory: 4.16 GB

Private Memory: 398 MB

Peak Working Set: 532 MB

IE Version: 11.0.9600.19035

User ID: IDnumber

Workbook Package Info: 1* - nb-NO, Query Groups: 0, fastCombine: Enabled, runBackgroundAnalysis: True.

Telemetry Enabled: True

Model Default Mode: Import

Snapshot Trace Logs: C:\Users\userinfo\AppData\Local\Microsoft\Power BI Desktop\FrownSnapShot1416353677.zip

Performance Trace Logs: C:\Users\userinfo\AppData\Local\Microsoft\Power BI Desktop\PerformanceTraces.zip

Enabled Preview Features: PBI_PythonSupportEnabled

Disabled Preview Features: PBI_shapeMapVisualEnabled PBI_newFromWeb PBI_SpanishLinguisticsEnabled CustomConnectors PBI_variationUIChange PBI_canvasTooltips PBI_showIncrementalRefreshPolicy PBI_compositeModels PBI_DB2DQ

Disabled DirectQuery Options: PBI_DirectQuery_Unrestricted TreatHanaAsRelationalSource

Cloud: GlobalCloud

DPI Scale: 100%

Supported Services: Power BI

Formulas:

section Section1;

shared timeseries = let Source = Csv.Document(File.Contents("C:\data\timeseries.csv"),[Delimiter=",", Columns=2, Encoding=1252, QuoteStyle=QuoteStyle.None]), #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]), #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Date", type date}, {"Value", Int64.Type}}) in #"Changed Type";

解决方案

OK now it's obvious where the error comes from.

In the line (which Power BI generates on the fly):

matplotlib.pyplot.figure(figsize=(5,87473572938689,6,87403100775194))

It grabs the dimensions in your locale (which in this case use ',' as decimal point) and passes it to figsize.

While figsize accepts a tuple of (width, height) in inches as input, 5,87473572938689,6,87403100775194 is treated as 4 arguments, instead of 2, which causes the error.


So to work around this, you can either explicitly pass figsize (using values with . as decimal point) to plt.figure, i.e.:

import matplotlib.pyplot as plt
plt.figure(figsize=(5.874,6.874))
plt.plot(dataset['Date'], dataset['Value'])
plt.show()

Or change the locale in Power BI to one which use . as decimal points instead of ,.

这篇关于Power BI中的Python可视化需要什么设置?是否有任何特定的matplotlib软件包版本或系统设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆