擅长:python、mysql、java
<p>您可以定义一个实现删除条件的函数,然后应用此函数选择行:</p>
<pre><code># This column represents rows satisfying the condition
bool_column = df.apply(lambda x: True if x[0] == 100 or x[1] == 101 else False, axis=1)
filtered_df = df[col.values] # Select rows with True condition
filtered_df = df[~col.values] # Select rows with False condition
</code></pre>
<p>在这里,这个函数被实现为lambda,但是在更复杂的计算中,它可以是一个普通的Python函数。如果条件中涉及的列太多,则也可以通过循环来实现自动化测向列. 此外,如果需要,可以在中向函数传递其他参数数据框应用. 你知道吗</p>