Shrink pandas Df by deleting rows through modulo
<p>I need to reduce (or select) for example multiple of 4 of the index.
i have a 2MS dataframe and i want to get less data for a future plot. so the idea is to work with 1/4 of the data. leaving only the rows with index 4 - 8 - 16 - 20 - 4*n (or maybe the same but with 5*n)
if someone has any idea i will be grateful.</p>

<p>You can use the <code>iloc</code> function, which takes a row/column slice. </p>

<p>From the <a href="http://pandas.pydata.org/pandas-docs/version/0.17.0/generated/pandas.DataFrame.iloc.html" rel="nofollow">docs</a></p>

<blockquote>
  <p>Purely integer-location based indexing for selection by position.</p>
  
  <p>.iloc[] is primarily integer position based (from 0 to length-1 of the
  axis), but may also be used with a boolean array.</p>
</blockquote>

<p>So you could write <code>df.iloc[::4, :]</code></p>

python pandas dataframe