-
-
Notifications
You must be signed in to change notification settings - Fork 19.4k
Open
Labels
EnhancementNeeds TriageIssue that has not been reviewed by a pandas team memberIssue that has not been reviewed by a pandas team member
Description
Feature Type
-
Adding new functionality to pandas
-
Changing existing functionality in pandas
-
Removing existing functionality in pandas
Problem Description
I wish I could use Pandas to return a random block of data from a DF.
Like .sample() but the data returned is contiguous, in essence the method randomly samples 1 row idx and then samples the next N from that point.
Feature Description
Add a contiguous param to .sample or create a new .sample_contgiuous
Draw from distribution a single idx
and select N around that as a contiguous block
Alternative Solutions
def random_contiguous_sample(df, n):
max_start = len(df) - n
start_idx = np.random.randint(0, max_start + 1)
return df.iloc[start_idx:start_idx + n]
Additional Context
No response
Metadata
Metadata
Assignees
Labels
EnhancementNeeds TriageIssue that has not been reviewed by a pandas team memberIssue that has not been reviewed by a pandas team member