-2

I'm having some problems with unique function after updating astropy

code:

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')

error in jupyter notebook

NameError: name 'unique' is not defined

error in terminal:

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

What can i do?

tephyr
  • 1,001
  • 2
  • 14
  • 26

1 Answers1

1

You'll have to import it from astropy.table:

from astropy.table import unique

The example in the documentation (that you use in your question) is incorrect.

The signature of the function in that same documentation page makes it clear where it comes from:

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