Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions datacompy/fugue.py
Original file line number Diff line number Diff line change
Expand Up @@ -928,9 +928,16 @@ def _aggregate_stats(


def _sample(df: pd.DataFrame, sample_count: int) -> pd.DataFrame:
if len(df) <= sample_count:
df_len = len(df)
if df_len <= sample_count:
if (
isinstance(df.index, pd.RangeIndex)
and df.index.start == 0
and df.index.step == 1
):
return df
return df.reset_index(drop=True)
return df.sample(n=sample_count, random_state=0).reset_index(drop=True)
return df.sample(n=sample_count, random_state=0, ignore_index=True)


class _StrictSchemaError(Exception):
Expand Down