卡号, 进站编号, 进站时间, 进站线路, 出站编号, 出站时间, 出站线路 S010xxxxxx05764320,0122,15:09:00,01,1351,13:56:31,13 S010xxxxxx24535560,9705,13:37:00,97,0201,14:38:23,02 S010xxxxxx54576320,0105,07:39:00,01,0201,08:18:13,02 S010xxxxxx07392730,9321,15:14:00,93,0439,15:23:25,04 S010xxxxxx97776930,0216,07:58:00,02,0201,08:10:12,02 S010xxxxxx73598630,0931,08:07:00,09,0201,08:33:03,02 S010xxxxxx52714840,0114,08:29:00,01,0201,08:41:16,02 S010xxxxxx01979600,0123,09:53:00,01,0201,10:32:13,02 S010xxxxxx09069140,0104,15:08:00,01,0104,13:50:18,01 S010xxxxxx95262390,0463,08:08:00,04,0201,08:33:17,02 S010xxxxxx07555490,1015,07:48:00,10,0813,10:13:19,08 S010xxxxxx07231460,9525,08:40:00,95,9525,08:40:23,95 S010xxxxxx67155570,1051,07:32:00,10,0201,08:16:10,02 S010xxxxxx76176560,9711,08:30:00,97,0201,09:49:04,02 S010xxxxxx07396920,0465,19:48:00,04,0929,13:55:01,09 S010xxxxxx05692400,0000,14:44:00,00,0651,16:44:22,06 S010xxxxxx69720040,0120,17:25:00,01,0201,17:52:12,02 S010xxxxxx50779513,0451,09:17:00,04,0201,09:39:34,02 S010xxxxxx09220040,9429,18:33:00,94,9429,19:26:47,94 S010xxxxxx01027320,0205,08:33:00,02,0201,08:45:12,02 S010xxxxxx09036180,0563,07:31:00,05,1081,13:07:07,10 S010xxxxxx83086320,0433,07:42:00,04,0201,07:59:14,02 S010xxxxxx09127310,0209,12:39:00,02,0209,05:28:10,02 S010xxxxxx09279440,1001,07:20:00,10,0108,09:27:23,01 S010xxxxxx36871830,0210,13:16:00,02,0201,13:42:25,02 S010xxxxxx42150840,0103,09:47:00,01,0201,10:32:17,02 S010xxxxxx71233940,0523,07:10:00,05,0201,07:55:01,02 S010xxxxxx76236920,0214,09:29:00,02,0201,09:50:14,02 S010xxxxxx07541710,0218,16:46:00,02,0117,09:13:14,01 设计python 程序对有问题的数据进行筛选和剔除,比如出站时间早于进站时间的记录, 从进站到出站不足5分钟的记录
时间: 2023-09-11 16:05:57 浏览: 139
卡号查询程序
好的,我可以为您设计一个Python程序来进行筛选和剔除数据。以下是示例代码:
```python
import datetime
def filter_data(records):
result = []
for record in records:
enter_time = datetime.datetime.strptime(record[2], '%H:%M:%S')
exit_time = datetime.datetime.strptime(record[6], '%H:%M:%S')
duration = (exit_time - enter_time).seconds // 60
if exit_time < enter_time or duration < 5:
continue
result.append(record)
return result
# 示例数据
records = [
['S010xxxxxx05764320', '0122', '15:09:00', '01', '1351', '13:56:31', '13'],
['S010xxxxxx24535560', '9705', '13:37:00', '97', '0201', '14:38:23', '02'],
['S010xxxxxx54576320', '0105', '07:39:00', '01', '0201', '08:18:13', '02'],
['S010xxxxxx07392730', '9321', '15:14:00', '93', '0439', '15:23:25', '04'],
['S010xxxxxx97776930', '0216', '07:58:00', '02', '0201', '08:10:12', '02'],
['S010xxxxxx73598630', '0931', '08:07:00', '09', '0201', '08:33:03', '02'],
['S010xxxxxx52714840', '0114', '08:29:00', '01', '0201', '08:41:16', '02'],
['S010xxxxxx01979600', '0123', '09:53:00', '01', '0201', '10:32:13', '02'],
['S010xxxxxx09069140', '0104', '15:08:00', '01', '0104', '13:50:18', '01'],
['S010xxxxxx95262390', '0463', '08:08:00', '04', '0201', '08:33:17', '02'],
['S010xxxxxx07555490', '1015', '07:48:00', '10', '0813', '10:13:19', '08'],
['S010xxxxxx07231460', '9525', '08:40:00', '95', '9525', '08:40:23', '95'],
['S010xxxxxx67155570', '1051', '07:32:00', '10', '0201', '08:16:10', '02'],
['S010xxxxxx76176560', '9711', '08:30:00', '97', '0201', '09:49:04', '02'],
['S010xxxxxx07396920', '0465', '19:48:00', '04', '0929', '13:55:01', '09'],
['S010xxxxxx05692400', '0000', '14:44:00', '00', '0651', '16:44:22', '06'],
['S010xxxxxx69720040', '0120', '17:25:00', '01', '0201', '17:52:12', '02'],
['S010xxxxxx50779513', '0451', '09:17:00', '04', '0201', '09:39:34', '02'],
['S010xxxxxx09220040', '9429', '18:33:00', '94', '9429', '19:26:47', '94'],
['S010xxxxxx01027320', '0205', '08:33:00', '02', '0201', '08:45:12', '02'],
['S010xxxxxx09036180', '0563', '07:31:00', '05', '1081', '13:07:07', '10'],
['S010xxxxxx83086320', '0433', '07:42:00', '04', '0201', '07:59:14', '02'],
['S010xxxxxx09127310', '0209', '12:39:00', '02', '0209', '05:28:10', '02'],
['S010xxxxxx09279440', '1001', '07:20:00', '10', '0108', '09:27:23', '01'],
['S010xxxxxx36871830', '0210', '13:16:00', '02', '0201', '13:42:25', '02'],
['S010xxxxxx42150840', '0103', '09:47:00', '01', '0201', '10:32:17', '02'],
['S010xxxxxx71233940', '0523', '07:10:00', '05', '0201', '07:55:01', '02'],
['S010xxxxxx76236920', '0214', '09:29:00', '02', '0201', '09:50:14', '02'],
['S010xxxxxx07541710', '0218', '16:46:00', '02', '0117', '09:13:14', '01']
]
# 筛选数据
filtered_records = filter_data(records)
# 输出结果
for record in filtered_records:
print(record)
```
在示例代码中,我们定义了一个名为 `filter_data` 的函数来进行数据筛选和剔除。该函数接受一个列表作为参数,其中每个元素表示一条记录。对于每条记录,我们使用 `strptime` 函数将进站时间和出站时间转换为 `datetime` 对象,并计算出站时间减去进站时间的分钟数。接着,我们根据题目要求,判断出站时间是否早于进站时间,以及进出站时间间隔是否小于5分钟,如果是则跳过该记录,否则将其添加到结果列表中。最后,我们输出筛选后的结果。
您可以将示例代码中的 `records` 替换为您的数据,运行程序即可得到结果。
阅读全文