Skip to content

DatetimeIndex::inferred_freq is misleading #5082

Open
@cancan101

Description

@cancan101

Looking at these three methods on DatetimeIndex:

    # alias to offset
    @property
    def freq(self):
        return self.offset

    @cache_readonly
    def inferred_freq(self):
        try:
            return infer_freq(self)
        except ValueError:
            return None

    @property
    def freqstr(self):
        return self.offset.freqstr

you would think that freqstr returns a string and inferred_freq and freq return "frequencies" (i.e. offsets). In reality inferred_freq is a string as well.

I am not sure of the best way to deal with this issue. At the very least I would suggest adding a inferred_freq_offset property. Perhaps also deprecate inferred_freq and create a inferred_freqstr.

Tracing this method, you find _FrequencyInferer::get_freq which returns a string rather than an Offset.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions