I am trying to get the 'data' and the 'target' of the iris setosa database, but I can't. For example, when I load the iris setosa directly from sklearn datasets I get a good result:
Program:
from sklearn import datasets
import numpy as np
iris = datasets.load_iris()
X = iris.data[:, [2, 3]]
y = iris.target
print('Class labels:', np.unique(y))
output:
Class labels: [0 1 2]
But if I try to load it directly from extension '.csv' I get the following error:
Program:
import pandas as pd
iris = pd.read_csv('iris.csv', header=None).iloc[:,2:4]
x = iris.data
y = iris.target
output:
'DataFrame' object has no attribute 'data'
Why does this happen?