python - 如何从 python 脚本返回 Azure ML 中的数据框

标签 python web-services azure dataframe azure-machine-learning-service

我有下面的Python脚本。我正在尝试返回创建的新数据框。不幸的是,我收到“NotImplementedError:”

请告诉我如何从 python 脚本返回 Azure ML 中的 Dataframe

代码:

def azureml_main(df) :

    therm_patterns,therm_missed_patterns = thermostat_phase(df)
    th_pat = json.loads(therm_patterns)
    missed_th_pat = json.loads(therm_missed_patterns)

    light_patterns, light_missed_patterns = light_phase(df)
    lt_pat = json.loads(light_patterns)
    missed_lt_pat = json.loads(light_missed_patterns)

    for j in range (0,len(lt_pat)):
        for i in range (0,len(lt_pat[0]['John'])):
            th_pat[0]['John'].append(lt_pat[0]['John'][i])
    for j in range (0,len(lt_pat)):
        for i in range (0,len(lt_pat[0]['Jane'])):
            th_pat[0]['Jane'].append(lt_pat[0]['Jane'][i])
    for j in range (0,len(lt_pat)):
        for i in range (0,len(lt_pat[0]['Jen'])):
            th_pat[0]['Jen'].append(lt_pat[0]['Jen'][i])

    for j in range (0,len(missed_lt_pat)):
        for i in range (0,len(missed_lt_pat[0]['John'])):
            missed_th_pat[0]['John'].append(missed_lt_pat[0]['John'][i])
    for j in range (0,len(missed_lt_pat)):
        for i in range (0,len(missed_lt_pat[0]['Jane'])):
            missed_th_pat[0]['Jane'].append(missed_lt_pat[0]['Jane'][i])
    for j in range (0,len(missed_lt_pat)):
        for i in range (0,len(missed_lt_pat[0]['Jen'])):
            missed_th_pat[0]['Jen'].append(missed_lt_pat[0]['Jen'][i])

    output = json.dumps(th_pat)

    df = pd.DataFrame.from_dict({k: v[0] for k, v in json.loads(output) 
    [0].items()}, 'index' ).rename_axis('User').reset_index()


    return df         

错误:

  Error 0085: The following error occurred during script evaluation, please  
  view the output log for more information:

   ---------- Start of error message from Python interpreter ----------
   Caught exception while executing function: Traceback (most recent call  
   last):

       File "C:\server\invokepy.py", line 211, in batch
       xdrutils.XDRUtils.DataFrameToRFile(outlist[i], outfiles[i], True)

       File "C:\server\XDRReader\xdrutils.py", line 54, in DataFrameToRFile
       xdrwriter.write_attribute_list(attributes)

       File "C:\server\XDRReader\xdrwriter2.py", line 155, in   
       write_attribute_list
       self.write_object(value)

       File "C:\server\XDRReader\xdrwriter2.py", line 215, in write_object
       write_func(flags, converted, missingIndices)

       File "C:\server\XDRReader\xdrwriter2.py", line 185, in write_objects
       self.write_object(value)

       File "C:\server\XDRReader\xdrwriter2.py", line 200, in write_object
       raise NotImplementedError('Python Bridge conversion table not    
       implemented for type [{0}]'.format(value.getType()))

       NotImplementedError: Python Bridge conversion table not implemented  
       for type [<type 'list'>]

       Process returned with non-zero exit code 1

最佳答案

看起来您的数据框包含元组作为列的值。截至目前,Azure 机器学习工作区不支持数据框中的元组。

关于python - 如何从 python 脚本返回 Azure ML 中的数据框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41586275/

相关文章:

python - Excel 工作表中不存在数据

javascript - 设备/服务器开发中的版本控制

java - 处理程序不记录来自 Web 服务的任何内容甚至不抛出错误(在使用 metro 的 tomcat 上)

java - Clojure - 找不到匹配的方法

python - 当在源中找不到 URL 时,从 Google 本地搜索中提取网站(URL)吗?

Python 列表中带有 for 循环的 IN 和 OR 运算符

c++ - 在 win7-64 位中通过 mingw 使用 boost.python 编译一些代码

java - 通过 Spring 集成以及 http header 调用 Soap 服务

azure - 我在 Azure 自动化的 PowerShell 中缺少什么,导致 Start-AzureVM 无法工作?

asp.net - IIS Azure 应用服务上的 SPA 应用程序