ENH: add ignore_index to DataFrame / Series.sample · Issue #38581 · pandas-dev/pandas (original) (raw)
Is your feature request related to a problem?
When sampling a dataframe / series we get the original index back by default, which is good, but we should add an option to ignore the index to keep it consistent with other methods like drop_duplicates
and explode
for example.
Describe the solution you'd like
Add ignore_index
argument to Series/DataFrame.sample.
API breaking implications
None as far as I can tell.
df = pd.DataFrame( {"col1": range(10, 20), "col2": range(20, 30), "colString": ["a"] * 10} ) df.sample(n=3, ignore_index=True)
col1 col2 colString 0 14 24 a 1 17 27 a 2 11 21 a