我现在被一些小数据集的基本问题所困扰。以下是前三行数据格式说明:
“运动”,“参赛”,“比赛日期”,“地点”,“积分”,“中奖非门票”,“获奖门票”,“比赛参赛作品”,“参赛费用”,“奖品池”,“场地费”
“NBA”,“NBA 3K交叉赛#3[3000保证](仅限早期)(1/15)”,“2015-03-01 13:00:00”,35283.25,“13.33”,“0.00”,171,“20.00”,“3000.00”,35
“NBA”,“NBA 1500上篮4[1500保证](仅提前)(1/25)”,“2015-03-01 13:00:00”,148283.25,“3.00”,“0.00”,862,“2.00”,“1500.00”,200
我在使用read_csv创建数据帧后遇到的问题:
在某些类别值(例如Prize_Pool)中出现逗号会导致python将这些条目视为字符串。我需要把这些转换成浮点数,以便进行某些计算。我已经使用python的replace()函数来去除逗号,但我已经做到了。
分类竞赛包含时间戳,但有些是重复的。我想将整个数据集子集为一个只有唯一时间戳的数据集。最好选择删除重复的条目,但目前我只希望能够用唯一的时间戳过滤数据。
对包含逗号的数字使用
thousands=','
参数你可以检查奖池是数字的
^{pr2}$要删除行-首先观察到,也可以选择最后一个
似乎
itertools.groupby()
是这项工作的工具像这样?在
输出:
更多信息:
https://docs.python.org/2/library/itertools.html
希望这有帮助:)
相关问题 更多 >
编程相关推荐