[英]Is Azure ML Studio support to import Excel file as Dataset?
聽起來您想在Azure Machine Learning Studio的實驗的“ Execute Python Script
模塊中讀取Excel文件。 根據官方文檔[ Execute Python machine learning scripts in Azure Machine Learning Studio][1]
,有兩種方法可以做到這一點,如下所示。
要將Excel文件上傳到Azure Blob存儲,請按照使用Azure Blob Storage SDK for Python讀取Accessing Azure Storage Blobs
一節中的說明進行操作。
請參閱“ Importing existing Python script modules
”部分,以將Excel文件與其他所需的Python包打包為zip文件,然后通過Azure ML Stodio自動提取,從zip文件的名為Script Bundle
的目錄中讀取它。
作為參考,我將向您展示第二種解決方案的詳細步驟,如下所示。
我准備了一個名為test.xlsx
的excel文件,其內容如下。
從其PyPi.org頁面下載xlrd
軟件包文件xlrd-1.2.0-py2.py3-none-any.whl
,然后將其壓縮文件提取到目錄test
,並使用test.xlsx
將其壓縮為zip文件。 test.zip
,如下所示。
我將zip文件test.zip
作為數據集上傳到Azure ML Studio,然后將其與Execute Python Script
模塊組裝在一起。
這是我的示例代碼。 我嘗試將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.