Skip to content

DatetimeIndex.intersection should preserve timezone #4690

Closed
@sboehler

Description

@sboehler

pandas' intersection method on DatetimeIndex should preserve the timezone. I had some cases where it works, and some where it doesn't. Example that does not work:

In [75]: a = pd.date_range('2012-01-01', '2012-01-20', freq='D', tz='CET')

In [76]: b = pd.date_range('2012-01-01', '2012-01-19', freq='D', tz='CET')

In [77]: a.intersection(b)
Out[77]: 
<class 'pandas.tseries.index.DatetimeIndex'>
[2011-12-31 23:00:00, ..., 2012-01-18 23:00:00]
Length: 19, Freq: D, Timezone: None

In [78]: pd.__version__
Out[78]: '0.12.0'

I would expect Timezone: CET in the output of line [77], and the times to be correctly displayed in CET.

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