Python新手,所以我需要一些帮助。在
我有一个CSV文件,它有一个id,created_at date,first/last name列。在
id created_at first_name last_name
1 1309380645 Cecelia Holt
2 1237178109 Emma Allison
3 1303585711 Desiree King
4 1231175716 Sam Davidson
我想过滤两个日期之间的行,比如03-22-2016
和04-15-2016
(日期并不重要),然后按升序排列这些行(通过created\u at)
我知道这个代码只会显示所有或大部分数据
^{pr2}$但我不确定如何完成剩下的工作,也不知道如何使用这个时间戳进行筛选1309380645
使用pandas
比使用csv对我更有利吗?在
任何帮助都是非常感谢的或一本指南/书阅读,以获得更多的理解。在
我建议使用pandas,因为它可以帮助您更快地过滤和执行进一步的分析。在
熊猫过滤解释:
首先需要知道的是,对dataframe使用比较运算符将返回一个带有布尔值的dataframe。在
^{pr2}$会回来的
现在,pandas支持逻辑索引。因此,如果将带有布尔值的数据帧传递给pandas,if将只返回与True相对应的值。在
退货
这就是你在熊猫身上很容易过滤的方法
下载和安装(和学习)
pandas
只是为了这样做似乎是太过分了。在以下是如何仅使用Python的内置模块来实现:
相关问题 更多 >
编程相关推荐