pandas 求助

查看 34|回复 0
作者:ohayoo   
我的 index 长这样:
MultiIndex([('2023-06-01 12:05:00', '1'),
('2023-06-01 12:05:00', '14'),
('2023-06-01 12:05:00', '2'),
('2023-06-01 12:05:00', '3'),
('2023-06-01 12:05:00', '4'),
('2023-06-01 12:05:00', '6'),
('2023-06-01 12:10:00', '1'),
('2023-06-01 12:10:00', '12'),
('2023-06-01 12:10:00', '14'),
('2023-06-01 12:10:00', '3'),
...
('2023-06-01 13:55:00', '1'),
('2023-06-01 13:55:00', '12'),
('2023-06-01 13:55:00', '13'),
('2023-06-01 13:55:00', '14'),
('2023-06-01 13:55:00', '15'),
('2023-06-01 13:55:00', '2'),
('2023-06-01 13:55:00', '3'),
('2023-06-01 13:55:00', '4'),
('2023-06-01 13:55:00', '6'),
('2023-06-01 13:55:00', '8')],
names=['time', 'id'], length=207)
我想要每 5 分钟 按值的大小升序排序,也就是要变成这样:
MultiIndex([('2023-06-01 12:05:00', '1'),
('2023-06-01 12:05:00', '2'),
('2023-06-01 12:05:00', '3'),
('2023-06-01 12:05:00', '4'),
('2023-06-01 12:05:00', '6'),
('2023-06-01 12:05:00', '14'),
('2023-06-01 12:10:00', '1'),
('2023-06-01 12:10:00', '3'),
('2023-06-01 12:10:00', '12'),
('2023-06-01 12:10:00', '14'),
...
('2023-06-01 13:55:00', '1'),
('2023-06-01 13:55:00', '2'),
('2023-06-01 13:55:00', '3'),
('2023-06-01 13:55:00', '4'),
('2023-06-01 13:55:00', '6'),
('2023-06-01 13:55:00', '8')
('2023-06-01 13:55:00', '12'),
('2023-06-01 13:55:00', '13'),
('2023-06-01 13:55:00', '14'),
('2023-06-01 13:55:00', '15'),],
names=['time', 'id'], length=207)
当然这个只是 index ,index 排序完之后 后面列的值要能跟着排序联动
不知道这样表达清楚了
您需要登录后才可以回帖 登录 | 立即注册

返回顶部