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:
- is there way create
periodobjects irregular durations using existing pandas functionality? - if not, suggest how modify pandas in order provide irregular duration
periodobjects? (this comment suggests might possible "using custom dateoffset classes appropriately crafted onoffset, rollforward, rollback, , apply methods")
notes
- the docstring
periodsuggests possible specify arbitrary durations5t"5 minutes". believe docstring incorrect. runningpd.period('2013-01-01', freq='5t')produces exceptionvalueerror: mult == 1 supported. have reported this issue. - the "time stamps vs time spans" section in pandas documentation states "for regular time spans, pandas uses
periodobjects scalar values ,periodindexsequences 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
Post a Comment