小编Erk*_*rin的帖子

Airflow db init 错误 - 无法为 GET /api/v1/connections 添加操作

我正在尝试在 CentOS8 机器上安装 Airflow 2.0.1 和 ansible。Python 版本 3.8.1。我按照 Airflow 文档中的建议制作了 pip 20.2.4。

我正在使用 postgresql 并且airflow db check成功了。但 db init 任务给出以下错误。我airflow db init手动尝试过,但结果是一样的:

ERROR - Failed to add operation for GET /api/v1/connections
Traceback (most recent call last):
  File "/opt/airflow/lib/python3.8/site-packages/connexion/apis/abstract.py", line 209, in add_paths
    self.add_operation(path, method)
  File "/opt/airflow/lib/python3.8/site-packages/connexion/apis/abstract.py", line 162, in add_operation
    operation = make_operation(
  File "/opt/airflow/lib/python3.8/site-packages/connexion/operations/__init__.py", line 8, in make_operation
    return spec.operation_cls.from_spec(spec, *args, **kwargs)
  File "/opt/airflow/lib/python3.8/site-packages/connexion/operations/openapi.py", line 128, in from_spec
    return cls(
  File "/opt/airflow/lib/python3.8/site-packages/connexion/operations/openapi.py", line 75, …
Run Code Online (Sandbox Code Playgroud)

centos airflow centos8

3
推荐指数
1
解决办法
7756
查看次数

Scikit-learn LabelEncoder:IndexError:用作索引的数组必须是整数(或布尔)类型

我正在尝试预处理成人数据以进行分类。我使用 scikit-learn 处理分类属性。

from sklearn.preprocessing import LabelEncoder
labelencoder = LabelEncoder()
X[:,0] = labelencoder.fit_transform(X[:,0])
labelencoder.classes_
Run Code Online (Sandbox Code Playgroud)

输出:

array(['Federal-gov', 'Local-gov', 'Private', 'Self-emp-inc',
       'Self-emp-not-inc', 'State-gov', 'Without-pay'], dtype=object)
Run Code Online (Sandbox Code Playgroud)

新内容:

X[:3]
array([[5, 'Bachelors', 'Under-Graduate', 'Never-married',
        'Adm-clerical', 'Not-in-family', 'White', 'Male',
        'United-States', 39.0, 77516.0, 13.0, 2174.0, 0.0, 40.0],
       [4, 'Bachelors', 'Under-Graduate', 'Married-civ-spouse',
        'Exec-managerial', 'Husband', 'White', 'Male', 'United-States',
        50.0, 83311.0, 13.0, 0.0, 0.0, 13.0],
       [2, 'HS-grad', 'HS-grad', 'Divorced', 'Handlers-cleaners',
        'Not-in-family', 'White', 'Male', 'United-States', 38.0,
        215646.0, 9.0, 0.0, 0.0, 40.0]], dtype=object)
Run Code Online (Sandbox Code Playgroud)

一切都很好,直到这里。但我需要查看原始属性并尝试返回以下内容:

original = labelencoder.inverse_transform(X[:,0])
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

IndexError                                Traceback (most recent …
Run Code Online (Sandbox Code Playgroud)

python scikit-learn categorical-data

0
推荐指数
1
解决办法
789
查看次数