#object #attributes #series
#объект #атрибуты #Серии
Вопрос:
Хотя я обновил свой пакет pandas, я все еще получаю ту же ошибку. Может ли кто-нибудь мне помочь?
AttributeError Traceback (most recent call last)
<ipython-input-11-15edd19aa9dd> in <module>
----> 1 telco=telco_numvar.apply(lambda x:outlier_capping(x))
E:anacondapathlibsite-packagespandascoreframe.py in apply(self, func, axis, raw, result_type, args, **kwds)
7539 kwds=kwds,
7540 )
-> 7541 return op.get_result()
7542
7543 def applymap(self, func) -> "DataFrame":
E:anacondapathlibsite-packagespandascoreapply.py in get_result(self)
178 return self.apply_raw()
179
--> 180 return self.apply_standard()
181
182 def apply_empty_result(self):
E:anacondapathlibsite-packagespandascoreapply.py in apply_standard(self)
253
254 def apply_standard(self):
--> 255 results, res_index = self.apply_series_generator()
256
257 # wrap results
E:anacondapathlibsite-packagespandascoreapply.py in apply_series_generator(self)
282 for i, v in enumerate(series_gen):
283 # ignore SettingWithCopy here in case the user mutates
--> 284 results[i] = self.f(v)
285 if isinstance(results[i], ABCSeries):
286 # If we have a view on v, we need to make a copy because
<ipython-input-11-15edd19aa9dd> in <lambda>(x)
----> 1 telco=telco_numvar.apply(lambda x:outlier_capping(x))
<ipython-input-9-df1facca9fe7> in outlier_capping(x)
1 # outlier treatment
2 def outlier_capping(x):
----> 3 x=x.clip_upper(x.quantile(0.99))
4 x=x.clip_lower(x.quantile(0.01))
5 return x
E:anacondapathlibsite-packagespandascoregeneric.py in __getattr__(self, name)
5128 if self._info_axis._can_hold_identifiers_and_holds_name(name):
5129 return self[name]
-> 5130 return object.__getattribute__(self, name)
5131
5132 def __setattr__(self, name: str, value) -> None:
AttributeError: 'Series' object has no attribute 'clip_upper'
Комментарии:
1. после обновления pandas по-прежнему получает ту же ошибку, что и у объекта ‘Series’, у которого нет атрибута ‘clip_upper’
Ответ №1:
Используйте, clip(upper=limit)
проверьте эту ссылку