<p dir="auto">It is very common to read random rows in a large csv file, typically for testing with a small dataset, or fit the limit of memory. The parameter <code class="notranslate">nrows</code> is used for read the first n lines, but I didn't find any feature to read random lines. Such parameter might be named <code class="notranslate">keeprows</code> (opposite to <code class="notranslate">skiprows</code>), which supports:</p>
<ul dir="auto">
<li>int, e.g. <code class="notranslate">keeprows=100</code> means keep 100 random lines (uniformly)</li>
<li>float in (0, 1), e.g. <code class="notranslate">keeprows=0.05</code> means keep 5% of total lines</li>
<li>list of int(or iterable), e.g. <code class="notranslate">keeprows=[1, 3, 8]</code> mean to keep line 1, 3, and 8</li>
</ul>
<p dir="auto">propose an option, <code class="notranslate">sample</code> or <code class="notranslate">keeprows</code> (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="178797807" data-permission-text="Title is private" data-url="https://github.com/pandas-dev/pandas/issues/14285" data-hovercard-type="issue" data-hovercard-url="/pandas-dev/pandas/issues/14285/hovercard" href="https://github.com/pandas-dev/pandas/issues/14285">#14285</a>)</p>
<p dir="auto">maybe taking a callable, for really just something like <code class="notranslate">sample=10</code></p>
<p dir="auto">to return you every 10th row</p>
<p dir="auto">if it takes a callbale couuld use something like: <code class="notranslate">lambda x: x % 10</code></p>
<p dir="auto">easy way to get a <code class="notranslate">sample</code> of the csv file</p>
<p dir="auto">useful to avoid specifying <code class="notranslate">skiprows</code> with a big list</p>
<p dir="auto">and to solve an issue like this:</p>
<p dir="auto"><a href="http://stackoverflow.com/questions/15555005/get-inferred-dataframe-types-iteratively-using-chunksize" rel="nofollow">http://stackoverflow.com/questions/15555005/get-inferred-dataframe-types-iteratively-using-chunksize</a></p>