title: i faced this problem while i was strat sampling the dataset
body: <pre><code>In [16] : Strat_d3=d3.groupby('Label', group_keys=False).apply(lambda x: x.sample(1000))
  Traceback (most recent call last):
  
    File &quot;&lt;ipython-input-16-f54910ba8f95&gt;&quot;, line 1, in &lt;module&gt;
      Strat_d3=d3.groupby('Label', group_keys=False).apply(lambda x: x.sample(1000))
  
    File &quot;C:\Users\Msi\anaconda3\lib\site-packages\pandas\core\groupby\groupby.py&quot;, line 894, in apply
      result = self._python_apply_general(f, self._selected_obj)
  
    File &quot;C:\Users\Msi\anaconda3\lib\site-packages\pandas\core\groupby\groupby.py&quot;, line 928, in _python_apply_general
      keys, values, mutated = self.grouper.apply(f, data, self.axis)
  
    File &quot;C:\Users\Msi\anaconda3\lib\site-packages\pandas\core\groupby\ops.py&quot;, line 238, in apply
      res = f(group)
  
    File &quot;&lt;ipython-input-16-f54910ba8f95&gt;&quot;, line 1, in &lt;lambda&gt;
      Strat_d3=d3.groupby('Label', group_keys=False).apply(lambda x: x.sample(1000))
  
    File &quot;C:\Users\Msi\anaconda3\lib\site-packages\pandas\core\generic.py&quot;, line 5350, in sample
      locs = rs.choice(axis_length, size=n, replace=replace, p=weights)
  
    File &quot;mtrand.pyx&quot;, line 959, in numpy.random.mtrand.RandomState.choice
  
  ValueError: Cannot take a larger sample than population when 'replace=False'
  </code></pre>