Astropy.table Unique() 不工作

Astropy.table Unique() not working

我在更新 astropy 后遇到一些独特功能的问题

代码:

from astropy.table import Table
import numpy as np
table = Table(data=[[1,2,3,2,3,3],[2,3,4,5,4,6],[3,4,5,6,7,8]],
    names=['col1', 'col2', 'col3'],
    dtype=[np.int32, np.int32, np.int32])

unique(table, keys='col1')

jupyter notebook 出错

NameError: name 'unique' is not defined

终端错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'unique' is not defined

我能做什么?

您必须从 astropy.table:

导入它
from astropy.table import unique

example in the documentation(您在问题中使用的)不正确。

同一文档页面中的函数签名清楚地表明了它的来源:

astropy.table.unique(input_table, keys=None, silent=False, keep='first')