推荐学习书目
› 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 · Dec 21, 2018 · 2693 views
    This topic created in 2843 days ago, the information mentioned may be changed or developed.
    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 replies  •  2018-12-22 16:52:13 +08:00
    wssy921
        1
    wssy921  
       Dec 21, 2018
    数组好好的,干嘛要拆他
    ruoyu0088
        2
    ruoyu0088  
       Dec 21, 2018   ❤️ 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
       Dec 22, 2018
    @ruoyu0088 谢谢帮助。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   835 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 19:09 · PVG 03:09 · LAX 12:09 · JFK 15:09
    ♥ Do have faith in what you're doing.