Skip to content

BUG: tz_localize drops freq from DatetimIndex #36575

Open
@giuliobeseghi

Description

@giuliobeseghi
  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • (optional) I have confirmed this bug exists on the master branch of pandas.


Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Code Sample, a copy-pastable example

import pandas as pd

s = pd.Series(
    [1, 2, 3, 4, 5], index=pd.date_range("2020", periods=5, freq="D")
)
print(s.index.freq)  # <Day>
print(s.tz_localize("europe/london").index.freq)  # None

Problem description

The index should retain the freq attribute despite localization.

Output of pd.show_versions()

It raises

ImportError: Can't determine version for hypothesis

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugFrequencyDateOffsetsTimezonesTimezone data dtypefreq retentionUser expects "freq" attribute to be preserved

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions