簡體   English   中英

Azure ML Studio是否支持將Excel文件導入為數據集?

[英]Is Azure ML Studio support to import Excel file as Dataset?

我正在使用Azure ML Studio並嘗試將Excel文件上傳為數據集。 但是,我沒有選擇它。 我想念什么嗎?

在此處輸入圖片說明

聽起來您想在Azure Machine Learning Studio的實驗的“ Execute Python Script模塊中讀取Excel文件。 根據官方文檔[ Execute Python machine learning scripts in Azure Machine Learning Studio][1] ,有兩種方法可以做到這一點,如下所示。

  1. 要將Excel文件上傳到Azure Blob存儲,請按照使用Azure Blob Storage SDK for Python讀取Accessing Azure Storage Blobs一節中的說明進行操作。

  2. 請參閱“ Importing existing Python script modules ”部分,以將Excel文件與其他所需的Python包打包為zip文件,然后通過Azure ML Stodio自動提取,從zip文件的名為Script Bundle的目錄中讀取它。

作為參考,我將向您展示第二種解決方案的詳細步驟,如下所示。

  1. 我准備了一個名為test.xlsx的excel文件,其內容如下。

    在此處輸入圖片說明

  2. 從其PyPi.org頁面下載xlrd軟件包文件xlrd-1.2.0-py2.py3-none-any.whl ,然后將其壓縮文件提取到目錄test ,並使用test.xlsx將其壓縮為zip文件。 test.zip ,如下所示。

    在此處輸入圖片說明

  3. 我將zip文件test.zip作為數據集上傳到Azure ML Studio,然后將其與Execute Python Script模塊組裝在一起。

    在此處輸入圖片說明

  4. 這是我的示例代碼。 我嘗試將os.getcwd()os.listdir()os.listdir('Script Bundle')與日志結合使用,以找到用於讀取zip文件中文件的正確路徑。

     import pandas as pd def azureml_main(dataframe1 = None, dataframe2 = None): import os print(os.getcwd()) print(os.listdir()) print(os.listdir('Script Bundle')) import xlrd file = 'Script Bundle/test.xlsx' data = xlrd.open_workbook(file) print([sheet.name for sheet in data.sheets()]) print('Input pandas.DataFrame #1:\\r\\n\\r\\n{0}'.format(dataframe1)) return dataframe1, 

它可以在Anaconda 4.0/Python 3.5 ,日志如下。

在此處輸入圖片說明

希望能幫助到你。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM