Alfred1984/interesting-python

'a' must be greater than 0 unless no samples are taken

Jameshu229 opened this issue · 1 comments

In [22]:

15

data.sample(15)


ValueError Traceback (most recent call last)
in
----> 1 data.sample(15)

c:\users\administrator\appdata\local\programs\python\python37-32\lib\site-packages\pandas\core\generic.py in sample(self, n, frac, replace, weights, random_state, axis)
4863 "provide positive value.")
4864
-> 4865 locs = rs.choice(axis_length, size=n, replace=replace, p=weights)
4866 return self.take(locs, axis=axis, is_copy=False)
4867

mtrand.pyx in mtrand.RandomState.choice()

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

这是怎么回事啊?

Check data.shape。I got the same problem, then i found i was calling sample for an empty Dataframe