V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
songdg
V2EX  ›  Python

请教如何拆分数组

  •  
  •   songdg · 2018-12-21 13:09:36 +08:00 · 1487 次点击
    这是一个创建于 1924 天前的主题,其中的信息可能已经有所发展或是发生改变。
    array([[135501,40], [135515, 10], [135545,20],[135553,30], [135558, 50], [135605,40], [135625, 18], [135655,60],[135659,10], [135700,70], [135705, 90, [135713,60],[135723,30], [135738, 20],[135745, 90, [135749,60],[135752,30], [135757, 20],[135758, 50]])
    数组的第一列为时间(时分秒),我想根据分钟把数组拆分成几个数组。
    3 条回复    2018-12-22 16:52:13 +08:00
    wssy921
        1
    wssy921  
       2018-12-21 17:37:17 +08:00
    数组好好的,干嘛要拆他
    ruoyu0088
        2
    ruoyu0088  
       2018-12-21 20:47:11 +08:00   ❤️ 1
    import numpy as np

    #a = ...

    loc = np.where(np.diff(a[:, 0] // 100))[0] + 1

    for arr in np.split(a, loc):

    print(arr)
    songdg
        3
    songdg  
    OP
       2018-12-22 16:52:13 +08:00
    @ruoyu0088 谢谢帮助。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2714 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 15:43 · PVG 23:43 · LAX 08:43 · JFK 11:43
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.