how to import DBSCAN labels-Python

189 Views Asked by At

I want to include DBSCAN labels as new column in previous Data that I generated using pd.read_csv command. I am running below line.

bit_data['DBSCAN']=dbscan.labels_.astype(int)

but I am getting this error.

IndexError Traceback (most recent call last) in () ----> 1 bit_data['DBSCAN']=dbscan.labels_.astype(int)

IndexError: only integers, slices (:), ellipsis (...), numpy.newaxis (None) and integer or boolean arrays are valid indices

1

There are 1 best solutions below

0
On

The error is on the left side.

That variable bit_data probably is an array, and does not allow a string index: bit_data['DBSCAN']

You probably meant to use a data frame