0

我想在 Azure ML 中的 DataFrame 中插入一个新列。数据存储在指定的存储中。当我运行代码时,我收到一条错误消息:

File "ev_kmeans_bayesianoptimization_2cluster.py", line 223, in calc_evaluation_kmeans_ev
df['label'] = ((df[HI] > limit)).astype('int')
File "/anaconda/envs/azureml_py36/lib/python3.6/site-packages/pandas/core/frame.py", line 2995, in __getitem__
indexer = self.columns.get_loc(key)
File "/anaconda/envs/azureml_py36/lib/python3.6/site-packages/pandas/core/indexes/base.py", line 2899, in get_loc
return self._engine.get_loc(self._maybe_cast_indexer(key))
File "pandas/_libs/index.pyx", line 107, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/index.pyx", line 131, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/hashtable_class_helper.pxi", line 1607, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas/_libs/hashtable_class_helper.pxi", line 1614, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'STAT_PHM_LONG_BESCHS_MW_VIBR_WERT'

我的代码直到该行如下所示:

def calc_evaluation_kmeans_ev(alpha, limit):
datastore_name = 'workspaceblobstore'

# get existing workspace
workspace = Workspace.from_config()

# retrieve an existing datastore in the workspace by name
datastore = Datastore.get(workspace, datastore_name)

# create a TabularDataset from 1 file paths in datastore
datastore_paths = [(datastore, 'UI/06-17-2021_031103_UTC/210614_MDR_PHM_Laufunruhe_long_alldata.txt')]

dataset = Dataset.Tabular.from_delimited_files(path=datastore_paths)
df = dataset.to_pandas_dataframe()

#Define column to be found in DataFrame
HI = "STAT_PHM_LONG_BESCHS_MW_VIBR_WERT"

#Define limt
limit = 0.0395

#Insert Column 'Label' (0 or 1): Value of this column depends on the value of column HI
df['label'] = ((df[HI] > limit)).astype('int')

有谁知道如何在 Azure ML 的 Python 中解决这个问题?

提前致谢!

4

0 回答 0