擅长:python、mysql、java
<p>如果日期列是索引,则使用.loc进行基于标签的索引,或使用.iloc进行位置索引。</p>
<p>例如:</p>
<pre><code>df.loc['2014-01-01':'2014-02-01']
</code></pre>
<p>请参见此处的详细信息<a href="http://pandas.pydata.org/pandas-docs/stable/dsintro.html#indexing-selection" rel="noreferrer">http://pandas.pydata.org/pandas-docs/stable/dsintro.html#indexing-selection</a></p>
<p>如果列是<strong>而不是索引,则有两种选择:</p>
<ol>
<li>使其成为索引(如果是时间序列数据,则为临时索引或永久索引)</li>
<li><code>df[(df['date'] > '2013-01-01') & (df['date'] < '2013-02-01')]</code></li>
</ol>
<p>一般说明见<a href="http://pandas.pydata.org/pandas-docs/stable/indexing.html#boolean-indexing" rel="noreferrer">here</a></p>
<p><em>注意:.ix已弃用。</em></p>