TypeError: import_optional_dependency() got an unexpected keyword argument 'errors'

TypeError: import_optional_dependency() got an unexpected keyword argument 'errors'

我正在尝试使用 Featuretools 为客户流失数据集开发自动化特征工程工作流。最终结果是一个函数,它为客户接收数据集和标签时间,并构建可用于训练机器学习模型的特征矩阵。

作为本练习的一部分,我尝试执行以下代码来绘制直方图并得到“TypeError: import_optional_dependency() 得到了一个意外的关键字参数 'errors'”。请帮助解决此类型错误。

import matplotlib.pyplot as plt
%matplotlib inline
plt.style.use('fivethirtyeight')
plt.rcParams['figure.figsize'] = (10, 6)

trans.loc[trans['actual_amount_paid'] < 250, 'actual_amount_paid'].dropna().plot.hist(bins = 30)
plt.title('Distribution of Actual Amount Paid')

下面是我收到的完整错误:

    ---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-32-7e19affd5fc1> in <module>
      4 plt.rcParams['figure.figsize'] = (10, 6)
      5 
----> 6 trans.loc[trans['actual_amount_paid'] < 250, 'actual_amount_paid'].dropna().plot.hist(bins = 30)
      7 plt.title('Distribution of Actual Amount Paid')

~\anaconda3\lib\site-packages\pandas\core\ops\common.py in new_method(self, other)
     63                     break
     64                 if isinstance(other, cls):
---> 65                     return NotImplemented
     66 
     67         other = item_from_zerodim(other)

~\anaconda3\lib\site-packages\pandas\core\arraylike.py in __lt__(self, other)
     35     def __ne__(self, other):
     36         return self._cmp_method(other, operator.ne)
---> 37 
     38     @unpack_zerodim_and_defer("__lt__")
     39     def __lt__(self, other):

~\anaconda3\lib\site-packages\pandas\core\series.py in _cmp_method(self, other, op)  
   4937         --------
   4938         >>> s = pd.Series(range(3))
-> 4939         >>> s.memory_usage()
   4940         152
   4941 

~\anaconda3\lib\site-packages\pandas\core\ops\array_ops.py in comparison_op(left, right, op)
    248     lvalues = ensure_wrapped_if_datetimelike(left)
    249     rvalues = ensure_wrapped_if_datetimelike(right)
--> 250 
    251     rvalues = lib.item_from_zerodim(rvalues)
    252     if isinstance(rvalues, list):

~\anaconda3\lib\site-packages\pandas\core\ops\array_ops.py in _na_arithmetic_op(left, right, op, is_cmp)
    137 
    138 def _na_arithmetic_op(left, right, op, is_cmp: bool = False):
--> 139     
    140     Return the result of evaluating op on the passed in values.
    141 

~\anaconda3\lib\site-packages\pandas\core\computation\expressions.py in <module>
     17 from pandas._typing import FuncType
     18 
---> 19 from pandas.core.computation.check import NUMEXPR_INSTALLED
     20 from pandas.core.ops import roperator
     21 

~\anaconda3\lib\site-packages\pandas\core\computation\check.py in <module>
      1 from pandas.compat._optional import import_optional_dependency
      2 
----> 3 ne = import_optional_dependency("numexpr", errors="warn")
      4 NUMEXPR_INSTALLED = ne is not None
      5 if NUMEXPR_INSTALLED:

TypeError: import_optional_dependency() got an unexpected keyword argument 'errors'

尝试升级pandas:

pip install pandas --upgrade