创建DataFrame
df = pd.DataFrame(np.array(([1, 2, 3], [4, 5, 6], [2, 3, 6])),columns=['one', 'two', 'three'])
df
执行筛选条件
执行筛选条件:one列 > 1 and three列 > 2
df_filter = df[(df['one'] >1) & (df['three'] > 2)]
df_filter

注意:每个筛选条件需要使用括号限制,and并列条件使用 &,or并列条件需要使用 |

本文介绍了如何使用Python的pandas库创建DataFrame,并演示了如何通过多条件筛选df数据,如df['one'] > 1 and df['three'] > 2。适合初学者理解DataFrame的基本操作和筛选技巧。

1万+

被折叠的 条评论
为什么被折叠?



