擅长:python、mysql、java
<p>从<a href="http://pandas.pydata.org/pandas-docs/stable/timeseries.html#datetimeindex-partial-string-indexing" rel="nofollow">docs</a>和<a href="http://pandas.pydata.org/pandas-docs/stable/timeseries.html#time-date-components" rel="nofollow">Time/Date Components</a>我知道您需要指定微秒的数量(与datetime对象相同):</p>
<pre><code>In [103]: df.loc["2015-12-02 14:02:10":"2015-12-02 14:02:19.899999"]
Out[103]:
Sell
DateTime
2015-12-02 14:02:16.829999 1.05905
2015-12-02 14:02:19.250000 1.05906
2015-12-02 14:02:19.859999 1.05906
</code></pre>
<p>或者使用<code>datetime</code>精确指定微秒数:</p>
<pre><code>In [104]: df.loc["2015-12-02 14:02:10":datetime(year=2015, month=12, day=2, hour=14, minute=2, second=20, microsecond=999999)]
Out[104]:
Sell
DateTime
2015-12-02 14:02:16.829999 1.05905
2015-12-02 14:02:19.250000 1.05906
2015-12-02 14:02:19.859999 1.05906
2015-12-02 14:02:20.470000 1.05906
</code></pre>