susanli2016 / NLP-with-Python

Scikit-Learn, NLTK, Spacy, Gensim, Textblob and more
2.74k stars 2.02k forks source link

ValueError: 'a' must be greater than 0 unless no samples are taken #28

Open QABoahene opened 3 years ago

QABoahene commented 3 years ago

I was trying to use this same concept for my dataset and got the error in the title. Could anybody help? I also checked the shape of the dataframe which was (56, 11).

The error message is below:


ValueError Traceback (most recent call last)

in 1 print('5 random songs with the highest positive sentiment polarity: \n') ----> 2 hps = data.loc[data['polarity'] == 0.3, ['titles']].sample().values 3 for h in hps: 4 print(h[0]) ~/anaconda3/lib/python3.7/site-packages/pandas/core/generic.py in sample(self, n, frac, replace, weights, random_state, axis) 5059 ) 5060 -> 5061 locs = rs.choice(axis_length, size=n, replace=replace, p=weights) 5062 return self.take(locs, axis=axis) 5063 mtrand.pyx in mtrand.RandomState.choice() ValueError: 'a' must be greater than 0 unless no samples are taken