擅长:python、mysql、java
<p>xarray文档中关于时间序列的部分是一个很好的资源:
<a href="http://xarray.pydata.org/en/stable/user-guide/time-series.html" rel="nofollow noreferrer">http://xarray.pydata.org/en/stable/user-guide/time-series.html</a></p>
<p>处理此问题的一个好方法是将特殊的<code>.dt</code>访问器与方法<code>.strftime</code>一起使用:</p>
<pre><code>day_str = ds.time.isel(time=-1).dt.strftime("%a, %b %d %H:%M").values
</code></pre>
<p>或者,在这种情况下</p>
<pre><code>day_str=ds.time.dt.strftime("%a, %b %d %H:%M").values[0]
</code></pre>
<p>通过这种方法,<code>'SST, ' + day_str</code>给出</p>
<pre><code>'SST, Tue, Oct 19 09:50'
</code></pre>