'Error : only integer scalar arrays can be converted to a scalar index How to solve?

I try to convert breast canser dataset to a dataframe and to use it but i got following error;

TypeError: only integer scalar arrays can be converted to a scalar index

#Import library
from sklearn.datasets import load_breast_cancer
import pandas as pd
#Load dataset
cancer = load_breast_cancer()
#Convert the sklearn.dataset cancer to a DataFrame.
df=pd.DataFrame(cancer.data,columns =[cancer.feature_names])
df['target']=pd.Series(data=cancer.target,index=df.index)
display(df['target'])


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source