Skip to content

Commit

Permalink
Only concat and drop_duplicates if more than one of {sample,head,tail…
Browse files Browse the repository at this point in the history
…} are present
  • Loading branch information
gordonhart authored and cosmicBboy committed Dec 16, 2021
1 parent 5f9c713 commit d3bc974
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pandera/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -2288,11 +2288,12 @@ def _pandas_obj_to_validate(
pandas_obj_subsample.append(
dataframe_or_series.sample(sample, random_state=random_state)
)
return (
dataframe_or_series
if not pandas_obj_subsample
else pd.concat(pandas_obj_subsample).drop_duplicates()
)
if not pandas_obj_subsample:
return dataframe_or_series
first, *rest = pandas_obj_subsample
if not rest:
return first
return pd.concat([first, *rest]).drop_duplicates()


def _handle_check_results(
Expand Down

0 comments on commit d3bc974

Please sign in to comment.