mardi 17 janvier 2017

Python : get random ten values from a pandas dataframe

I am trying to build an algorithm for finding number of clusters. I need to assign random points from a data set as initial means.

I first tried the following code :

mu=random.sample(df,10) 

it gave index out of range error.

I converted the same into a numpy array and then did

mu=random.sample(np.array(df).tolist(),10)

instead of giving 10 values as mean it is giving me 10 arrays of values.

How can I get a 10 values to initialise as mean for 10 clusters from the dataframe?




Aucun commentaire:

Enregistrer un commentaire