如何修复'Series'对象在jypterLab中没有属性'reshape'

问题描述 投票:0回答:1

This is my code for the music recommendatin system.

这是错误,。

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-19-b58e57e00aac> in <module>
      2 print (query_index)
      3 
----> 4 distances, indices = model_knn.kneighbors(wide_artist_data.iloc[query_index, :].reshape(1, -1), n_neighbors = 6)
      5 
      6 for i in range(0, len(distances.flatten())):

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\generic.py in __getattr__(self, name)
   5272             if self._info_axis._can_hold_identifiers_and_holds_name(name):
   5273                 return self[name]
-> 5274             return object.__getattribute__(self, name)
   5275 
   5276     def __setattr__(self, name: str, value) -> None:

AttributeError: 'Series' object has no attribute 'reshape'
python attributeerror recommendation-engine
1个回答
0
投票
AttributeError: 'Series' object has no attribute 'reshape'

pandas.Series.reshape文档说:

从版本0.19.0开始不推荐使用:调用此方法将引发错误。请打电话改为.values.reshape(...)

它将是wide_artist_data.iloc[query_index, :].values.reshape(1, -1)

© www.soinside.com 2019 - 2024. All rights reserved.