Skip to content

Wrong indexing with time zone support #2897

Closed
@pkaczynski

Description

@pkaczynski

There is something really wrong with ix method while using time support. Simple example:

def test_tz_error(self):
        import pandas, pytz
        from datetime import datetime
        from datetime import timedelta as td
        tz = pytz.timezone('Europe/Warsaw')
        ts_from = tz.localize(datetime(2012, 1, 1, 0, 0))
        ts_to = tz.localize(datetime(2012, 1, 1, 23, 0))
        ttt = pandas.DataFrame(index=pandas.date_range(ts_from, ts_to, freq='H'), 
                               columns=['values'])
        ttt['value'] = range(1,25)
        ts = ts_from
        while ts <= ts_to:
            print ttt.ix[ts]['value']
            ts += td(hours=1)

Should print out number 1,2,3,...,24. However i get:
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 24

Why is it from 2, not 1? And why the last value is repeated twice with value 24??

I am using latest release 0.10.1

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