0

调用 drop.duplicate 函数时出现此错误:

Traceback (most recent call last):
  File "train.py", line 159, in <module>
    orders_dfx = preprocess_orders(orders_df)
  File "train.py", line 20, in preprocess_orders
    ao = ao.drop_duplicates(subset=['order_id'], keep='last')
AttributeError: 'TabularDataset' object has no attribute 'drop_duplicates'

这是train.py代码的一部分

def preprocess_orders(ao):
  ao = ao.drop_duplicates(subset=['order_id'], keep='last')
  ao['order_id'] = ao['order_id'].astype('str')
  ao['class'] = ao['class'].astype('int')
  ao['age'] = ao['age'].astype('float').fillna(ao['age'].mean()).round(2)
  return ao

orders_df = Dataset.get_by_name(ws, name='class_cancelled_orders')
orders_df.to_pandas_dataframe()
# Doing processing
orders_dfx = preprocess_orders(orders_df)

我正在从 azureml studio 中的数据集中获取数据。job.py 文件用于运行实验:

# submit job
run = Experiment(ws, experiment_name).submit(src)
run.wait_for_completion(show_output=True)
4

1 回答 1

1

to_pandas_dataframe()方法返回一个 pandas DataFrame,因此您需要将其分配回您的变量:

orders_df = orders_df.to_pandas_dataframe()
于 2021-03-06T11:54:11.630 回答