Skip to content

Commit 7b9aac4

Browse files
committed
doc: minior adjustments
1 parent c4241fb commit 7b9aac4

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

doc/source/whatsnew/v0.16.1.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ when sampling from rows.
209209

210210
.. ipython:: python
211211
212-
df = pd.DataFrame({"col1": [9, 8, 7, 6], "weight_column": [0.5, 0.4, 0.1, 0]})
213-
df.sample(n=2, weights="weight_column")
212+
df = pd.DataFrame({"col1": [9, 8, 7, 6], "weight_column": [0.5, 0.4, 0.1, 0]})
213+
df.sample(n=2, weights="weight_column")
214214
215215
216216
.. _whatsnew_0161.enhancements.string:

pandas/core/generic.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5814,7 +5814,7 @@ def sample(
58145814
If weights do not sum to 1, they will be normalized to sum to 1.
58155815
Missing values in the weights column will be treated as zero.
58165816
Infinite values not allowed.
5817-
When replace = False will not allow ``(n * max(weights) / sum(weights)) > 1``,
5817+
When replace = False will not allow ``(n * max(weights) / sum(weights)) > 1``
58185818
in order to avoid biased results. See the Notes below for more details.
58195819
random_state : int, array-like, BitGenerator, np.random.RandomState, np.random.Generator, optional
58205820
If int, array-like, or BitGenerator, seed for random number generator.
@@ -5853,8 +5853,9 @@ def sample(
58535853
If `frac` > 1, `replacement` should be set to `True`.
58545854
58555855
When replace = False will not allow ``(n * max(weights) / sum(weights)) > 1``,
5856-
since that would cause results to be biased. E.g. sampling 2 items without replacement,
5857-
with weights [100, 1, 1] would yield two last items in 1/2 of cases, instead of 1/102
5856+
since that would cause results to be biased. E.g. sampling 2 items without replacement
5857+
with weights [100, 1, 1] would yield two last items in 1/2 of cases, instead of 1/102.
5858+
This is similar to specifying `n=4` without replacement on a Series with 3 elements.
58585859
58595860
Examples
58605861
--------

0 commit comments

Comments
 (0)