Reputation: 1608
I am learning about unsupervised machine learning with scikit learn. I have collected so data from online. when I try to apply scatter plot I am getting following error
IndexingError: Too many indexers
Here is the code:
data = arff.loadarff("./Data/Arrhythmia/Arrhythmia_withoutdupl_02_v01.arff")
df = pd.DataFrame(data[0])
df = df.drop(['outlier',"id"],axis=1)
X_com = df.att10
plt.scatter(X_com.iloc[:,0],X_com.iloc[:,1])
plt.show()
I want to apply here KMeans
algorithm from scikit learn. What I am doing wrong ? Thanks in advance
Upvotes: 1
Views: 288
Reputation: 16966
May be you want to see the spread of data, with respect to first two features. Then you have to slice it from the initial dataset instead from Series (as @Alexandre metioned)
data = arff.loadarff("./Data/Arrhythmia/Arrhythmia_withoutdupl_02_v01.arff")
df = pd.DataFrame(data[0])
df = df.drop(['outlier',"id"],axis=1)
plt.scatter(df.iloc[:,0],df.iloc[:,1])
plt.show()
Upvotes: 0
Reputation: 88285
X_com is a pd.Series, so when you're trying to slice it using .iloc, you can only specify one axis.
Upvotes: 3