Skip to content

Commit

Permalink
Raise error in sample() if n and frac are both passed (#3091)
Browse files Browse the repository at this point in the history
  • Loading branch information
cnpryer committed Apr 8, 2022
1 parent 0136482 commit 806b63f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions py-polars/polars/internals/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -4766,6 +4766,9 @@ def sample(
└─────┴─────┴─────┘
"""
if n is not None and frac is not None:
raise ValueError("n and frac were both supplied")

if n is None and frac is not None:
return self._from_pydf(self._df.sample_frac(frac, with_replacement, seed))

Expand Down
3 changes: 3 additions & 0 deletions py-polars/polars/internals/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -3045,6 +3045,9 @@ def sample(
]
"""
if n is not None and frac is not None:
raise ValueError("n and frac were both supplied")

if n is None and frac is not None:
return wrap_s(self._s.sample_frac(frac, with_replacement, seed))

Expand Down

0 comments on commit 806b63f

Please sign in to comment.