【问题标题】:PowerBI is not passing over the datafield to the Python scriptPowerBI 没有将数据字段传递给 Python 脚本
【发布时间】:2019-11-10 05:58:20
【问题描述】:

我正在尝试在 PowerBI 中运行一个简单的 Python 脚本以使其正常工作,但它只会出现许多错误。我尝试过:

  1. 重新安装 Numpy 和 Matplotlib。
  2. 尝试使用 Python 3.5 和 3.6
  3. 卸载 Conda 并重新安装

我有一个显示我的问题的屏幕截图(它都适合下面的一个屏幕)。对于标记为“标签”和“数据”的 x 和 y,数据只是 a、b、c 和 1、2、3。

Screen shot of error and code

代码在这里:

# The following code to create a dataframe and remove duplicated rows is always executed and acts as 
a preamble for your script: 
dataset = pandas.DataFrame(Data, Label)
# dataset = dataset.drop_duplicates()

# Paste or type your script code here:

import matplotlib.pyplot as plt 
dataset.plot(kind='scatter', x='Label', y='Data', color='red')
plt.show() 

【问题讨论】:

  • 脚本中的“a preamble for your script:”行被注释掉了
  • 有没有注释掉dataset = pandas.DataFrame(Data, Label),然后运行

标签: python numpy anaconda powerbi-desktop


【解决方案1】:

您需要注释掉以下内容:

dataset = pandas.DataFrame(Data, Label)

即使它被“注释掉”,它也会运行。它只是为可视化设置了数据框,如果没有注释掉,这是一个无效的示例:

希望有帮助

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-09-15
    • 2016-09-02
    • 2012-12-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多