python - Irregular, non-contiguous Periods in Pandas -


i need represent sequence of events. these events little unusual in are:

  • non-contiguous
  • non-overlapping
  • irregular duration

for example:

  • 1200 - 1203
  • 1210 - 1225
  • 1304 - 1502

i represent these events using pandas.periodindex can't figure out how create period objects irregular durations.

i have 2 questions:

  1. is there way create period objects irregular durations using existing pandas functionality?
  2. if not, suggest how modify pandas in order provide irregular duration period objects? (this comment suggests might possible "using custom dateoffset classes appropriately crafted onoffset, rollforward, rollback, , apply methods")

notes

  1. the docstring period suggests possible specify arbitrary durations 5t "5 minutes". believe docstring incorrect. running pd.period('2013-01-01', freq='5t') produces exception valueerror: mult == 1 supported. have reported this issue.
  2. the "time stamps vs time spans" section in pandas documentation states "for regular time spans, pandas uses period objects scalar values , periodindex sequences of spans. better support irregular intervals arbitrary start , end points forth-coming in future releases." (my emphasis)

update 1

building period custom duration looks pretty straightforward. but think main stumbling block persuading periodindex accept periods different freqs. e.g.:

in [93]: pd.periodindex([pd.period('2000', freq='d'),                           pd.period('2001', freq='t')])  valueerror: 2001-01-01 00:00 wrong freq 

it looks central assumption in periodindex every period has same freq.

a possible solution, depending on application, bin data creating periodindex has period equal smallest unit of time resolution need in order handle data , divide data amongst bins each event, leaving remaining bins null.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -