Skip to content

Commit

Permalink
Fix for "ValueError: Cannot take a larger sample than population when…
Browse files Browse the repository at this point in the history
… 'replace=False'"
  • Loading branch information
perfectly-preserved-pie committed Aug 11, 2023
1 parent 5a105d0 commit a515344
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ def is_numeric_col(df, column_name):
if pd.api.types.is_numeric_dtype(df[column_name].dtype):
return True
# If dtype is object, sample some rows and test if they can be converted to numbers
sample_values = df[column_name].dropna().sample(min(100, len(df))).tolist() # Sample at most 100 non-null values
non_na_values = df[column_name].dropna() # Drop NA values
sample_values = non_na_values.sample(min(100, len(non_na_values))).tolist()
try:
# Try converting the sample values to numbers
[float(x) for x in sample_values]
Expand Down

0 comments on commit a515344

Please sign in to comment.