Pandas time subset time series - dates ABOVE certain time
<p>If <code>df[:'2012-01-07']</code> returns the sub-DataFrame with dates below <code>20120107</code>, what does return dates <em>above</em> 20120107? <code>df['2012-01-07':]</code> doesn't...</p>

<p>For me it works perfect, but maybe in real data need sort index by <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.sort_index.html" rel="nofollow"><code>sort_index</code></a>:</p>

<pre><code>df = pd.DataFrame({'a':[0,1,2,5,4]}, index=pd.date_range('2012-01-05', periods=5))
print (df)

#if need ascending sorting
df = df.sort_index()
            a
2012-01-05  0
2012-01-06  1
2012-01-07  2
2012-01-08  5
2012-01-09  4

print (df[:'2012-01-07'])
            a
2012-01-05  0
2012-01-06  1
2012-01-07  2

print (df['2012-01-07':])
            a
2012-01-07  2
2012-01-08  5
2012-01-09  4
</code></pre>

<hr>

<pre><code>df = pd.DataFrame({'a':[0,1,2,5,4]}, index=pd.date_range('2012-01-05', periods=5))

#descending sorting
df = df.sort_index(ascending=False)

print (df)
            a
2012-01-09  4
2012-01-08  5
2012-01-07  2
2012-01-06  1
2012-01-05  0

print (df[:'2012-01-07'])
            a
2012-01-09  4
2012-01-08  5

print (df['2012-01-07':])
            a
2012-01-07  2
2012-01-06  1
2012-01-05  0
</code></pre>

python pandas indexing dataframe time-series