擅长:python、mysql、java
<p>第一部分很简单。使用<code>pd.Series.between</code>:</p>
<pre><code>df = df[df.year.between(1987, 2017)]
</code></pre>
<p>如果<code>year</code>未排序,我建议先排序<code>df</code>,然后使用<code>sort_values(subset='year')</code>进行排序。在</p>
<p>在下一部分中,一个解决方案将涉及生成一个<code>dict</code>映射,然后使用<code>map</code>将{<cd7>}转换为映射字符串,并对其进行分组。在</p>
^{pr2}$