Bill
Bill

Reputation: 1257

Creating unevenly distributed events with Pandas

Is it possible to generate time based events that are unevenly distributed using Pandas? I'm currently using this, but am trying to have variation in how evenly these events are distributed across the series.

rng = date_range('1/1/2011', periods=60*3, freq='S')
ts = Series(0, index=rng)

Upvotes: 1

Views: 87

Answers (1)

JohnE
JohnE

Reputation: 30424

Here's some example code based on the discussion in the comments. You can set '0.50' to be any percentage to keep.

import numpy as np
ts = Series( np.random.uniform(0,1,180), index=rng)
ts[ ts < 0.50 ].dropna()

2011-01-01 00:00:00    0.283262
2011-01-01 00:00:01    0.200472
2011-01-01 00:00:04    0.077024
2011-01-01 00:00:06    0.041452

Upvotes: 2

Related Questions