Skip to content

BUG: DatetimeIndex with nanosecond frequency does not include end #13672

Closed
@ChadFulton

Description

@ChadFulton

I'm not sure if this is a bug or intended behavior, but documentation says "If periods is none, generated index will extend to first conforming time on or just past end argument", and it appears here that in the nanosecond frequency case, the generated index only extends to just before the end argument.

Code Sample, a copy-pastable example if possible

> start = pd.Timestamp(1)
> end = pd.Timestamp(4)
> pd.DatetimeIndex(start=start, end=end, freq='N')
DatetimeIndex(['1970-01-01 00:00:00.000000001',
               '1970-01-01 00:00:00.000000002',
               '1970-01-01 00:00:00.000000003'],
              dtype='datetime64[ns]', freq='N')

whereas a similar call with annual frequency gives:

> start = pd.Timestamp('1971')
> end = pd.Timestamp('1974')
> pd.DatetimeIndex(start=start, end=end, freq='AS')
DatetimeIndex(['1971-01-01',
               '1972-01-01',
               '1973-01-01',
               '1974-01-01'],
              dtype='datetime64[ns]', freq='AS-JAN')

output of pd.show_versions()

pandas: 0.18.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions