Skip to content

Instantly share code, notes, and snippets.

@mdengler
Created May 26, 2016 00:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdengler/06505092587950f6ae2d5ba16da456f2 to your computer and use it in GitHub Desktop.
Save mdengler/06505092587950f6ae2d5ba16da456f2 to your computer and use it in GitHub Desktop.
every_nth = [2, 3]
index = pd.Series(range(len(df.index))) # or just df.index if it's already the 0-indexed indices
mask = reduce(np.logical_or, [index % i == 0 for i in every_nth])
df[mask.astype(bool).values]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment