I am trying to process create a pandas dataframe column and access the column by using its column name which gives an error KeyError: 'cluster'
Code
import pandas as pd
from scipy.cluster.hierarchy import fclusterdata
max_dist = 3
points = [(3, 2), (6, 2), (6, 5), (10, 1), (12, -2), (5, 7)]
clusters = fclusterdata(points, t=max_dist, criterion='distance')
clustered_points = (pd.DataFrame(points, columns=['x', 'y'], index=clusters)
.rename_axis(index='cluster'))
clustered_points['cluster']
How this error can be solved.