擅长:python、mysql、java
<p>似乎您需要<a href="https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.diff.html" rel="nofollow noreferrer">^{<cd1>}</a>和<code>groupby</code>:</p>
<pre><code>df['Quantity Traded'].diff().groupby(df['Security Name'],sort=False).last()
</code></pre>
<hr/>
<pre><code>Security Name
Max Pro -500.0
AVG 1500.0
</code></pre>