pandas - Pandas - 根据变量值过滤数据框
问题描述
我有一个存储索引值的变量。我正在尝试根据存储在此变量中的值过滤数据框。
下面给出了这些值的方式:
var = 2 <-- this stores the value for the variable. Now I am trying to create a copy of the Dataframe with only this column.
下面给出了我的数据框是如何的:
0,1,2,3,4
apple,4,3,4,5
orange,3,4,5,6
bananas,5,3,5,6
由于变量值为var = 2
,我正在尝试创建一个只有第二列的新数据框。下面给出了预期的输出:
2
3
4
3
解决方案
推荐阅读
- apache-spark - 如何在 Google Dataproc 主节点上启用 pyspark HIVE 支持
- c# - 使用 Linq 转置自定义集合
- sql-server - T-SQL 选择不同的格式化日期时间,同时仍排序为未格式化的日期时间
- css - How to properly resize dropdown menu in CSS?
- vb.net - 在 Visual Basic (Visual Studio 2019) 中运行时创建的 ListView 中的索引选择
- java - 如何在 Java 中实现 A*?
- java - Java - 将值输入 JTextArea 后事件之间的延迟
- java - 尝试编写一个函数以在发生错误时返回 false
- raku - 在 Raku 中混合私有和公共属性和访问器
- tvos - tvOS 究竟何时清除数据?