擅长:python、mysql、java
<p>它取决于数据,如果指定了频率,请使用<a href="http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DatetimeIndex.freqstr.html" rel="nofollow noreferrer">^{<cd1>}</a>:</p>
<pre><code>print (df.index.freqstr)
20T
</code></pre>
<p>如果未指定,则可以通过converterted DatetimeIndex与<a href="http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.asfreq.html" rel="nofollow noreferrer">^{<cd2>}</a>进行比较:</p>
<pre><code>idx = df.asfreq('20T').index
m = (df.index == idx).all()
print (m)
True
print (idx.freqstr)
20T
</code></pre>