擅长:python、mysql、java
<p>我只想使用numpy的<code>randn</code>:</p>
<pre><code>In [11]: df = pd.DataFrame(np.random.randn(100, 2))
In [12]: msk = np.random.rand(len(df)) < 0.8
In [13]: train = df[msk]
In [14]: test = df[~msk]
</code></pre>
<p>为了证明这一点:</p>
<pre><code>In [15]: len(test)
Out[15]: 21
In [16]: len(train)
Out[16]: 79
</code></pre>