擅长:python、mysql、java
<p>这是我的解决方案,让我知道这是否适合你。你知道吗</p>
<pre><code>d = {'legs': [2.051, 4.07, 8.298, 0.234],'wings': [2.05, 4.179,8.903,0.294],'seen': ['five', 'one', 'two', 'four']} #dictionary
df = pd.DataFrame(data=d).round(2)#creating the dataframe and also rounding it to 2 decimal
</code></pre>
<p>原始数据帧的输出:</p>
<pre><code> legs wings seen
0 2.05 2.05 five
1 4.07 4.18 one
2 8.30 8.90 two
3 0.23 0.29 four
df_new = df[df['legs'] != df['wings']] #this will apply the condition and assign it to new dataframe or anything else.
df_new
</code></pre>
<p>输出:</p>
<pre><code> legs wings seen
1 4.07 4.18 one
2 8.30 8.90 two
3 0.23 0.29 four
</code></pre>