我正在尝试将 dask-mlQuantileTransformer
转换应用于percentage
字段,并percentage_qt
在同一数据框中创建一个新字段。但我得到了错误Array assignment only supports 1-D arrays
。如何使这项工作?
import pandas as pd
import dask.dataframe as dd
from dask_ml.preprocessing import QuantileTransformer
mydict = [{'percentage': 12.1, 'b': 2, 'c': 3, 'd': 4},
{'percentage': 10.2, 'b': 200, 'c': 300, 'd': 400},
{'percentage': 11.3, 'b': 2000, 'c': 3000, 'd': 4000 }]
df = pd.DataFrame(mydict)
ddf = dd.from_pandas(df, npartitions=10)
qt = QuantileTransformer(n_quantiles=100)
x = ddf[['percentage']]
y = qt.fit_transform(x)
ddf['percentage_qt'] = y # <-- error happens here