search

Home  >  Q&A  >  body text

python - How to use pandas to process minute data into hourly lines?

                    code    open    high    low     close

date
2017-04-10 09:01:00 jd1709 3992.0 3992.0 3982.0 3984.0
2017-04-10 09:02:00 jd1709 3985.0 3988.0 3980.0 3986.0
2017- 04-10 09: 03:00 jd1709 3986.0 3986.0 3973.0 3977.0
2017-04-10 09:04:00 jd1709 3977.0 3983.0 3974.0 3981.0

Like the pandas df data above, I want to transform it into an hourly line, but due to irregular grouping, resample('H') cannot be used
For example, from 21:00-22:00, 22:00-23:00, 23:00-9:30, 9:30-10:45 such customized group summary
Please tell me how to implement it, thank you

仅有的幸福仅有的幸福2756 days ago1018

reply all(1)I'll reply

  • 迷茫

    迷茫2017-05-18 11:02:52

    Write a class to define the content field of the hour line
    Then read the tuple line by line and record the ohlc of the hour line
    Generate a new bar if the time meets the conditions

    reply
    0
  • Cancelreply