Astropy.table Unique()不起作用

时间:2017-11-20 23:34:47

标签: python python-3.x python-2.7 astropy

我在更新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笔记本中的

错误

NameError: name 'unique' is not defined
终端

错误

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

我该怎么办?

1 个答案:

答案 0 :(得分:1)

您必须从astropy.table

导入它
from astropy.table import unique

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

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

  

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