Link to the (unanswred) stackoverflow question which contains more details.
Problem description
The problem concerns the use of a step / frequency with infinite decimals. For instance to obtain a DatetimeIndex at a frequency of 300Hz one would try:
pd.date_range(start=0, periods=300, freq='3333333ns') # start on UNIX epoch because I do not care
with result
DatetimeIndex([ '1970-01-01 00:00:00',
'1970-01-01 00:00:00.003333333',
'1970-01-01 00:00:00.006666666',
'1970-01-01 00:00:00.009999999',
...
'1970-01-01 00:00:00.989999901',
'1970-01-01 00:00:00.993333234',
'1970-01-01 00:00:00.996666567'],
dtype='datetime64[ns]', length=300, freq='3333333N')
Expected Output
As can be seen there is a deviation since at the end I would like to have a time o 00:00:00.996666666 (i.e. a step of 1/300=0.0033333333).
The stackoverflow question proposes a workaround. But it results in an index that has no frequency (freq=None):
> date_range_fs(1, 300)
DatetimeIndex([ '1970-01-01 00:00:00',
'1970-01-01 00:00:00.003333333',
'1970-01-01 00:00:00.006666666',
'1970-01-01 00:00:00.010000',
...
'1970-01-01 00:00:00.990000',
'1970-01-01 00:00:00.993333333',
'1970-01-01 00:00:00.996666666'],
dtype='datetime64[ns]', length=300, freq=None)
My question is, would it be worth adding a Hz unit wich would automatically handle the problem of infinite decimals steps. This would probably be achieved by keeping the frequency in the background and recomputing the steps only when needed.
Any interest on that ?
Comment From: jreback
out of scope. I suppose you could add a cookbook recipe, but this is pretty niche.