Skip to content

Pandas compatibility of Timezone / Timezone Info #131

@frensjan

Description

@frensjan

I think there is an incompatibility between pandas and pendulum.tz.timezone.Timezone. I'm not sure who is to blame though, but as from pendulum.tz.timezone_info.TimezoneInfo it seemed reasonable to check here first.

Two examples of unexpected behaviour; the programs exit with a segmentation fault:

from datetime import datetime, timedelta

from pendulum.tz.timezone import UTCTimezone
from pendulum.tz.timezone_info import UTC
import pandas as pd
import pendulum

This program creates two date time ranges, but printing (creating a string representation) fails for the second:

tomorrow = pendulum.tomorrow()

print(pd.date_range(today.astimezone('UTC'), tomorrow.astimezone('UTC'), freq='1H'))
print(pd.date_range(today.astimezone('CET'), tomorrow.astimezone('CET'), freq='1H'))  # seg faults

In this example using UTCTimezone causes the segmentation fault:

tomorrow = datetime.now() + timedelta(hours=24)
now = datetime.now()

r = pd.date_range(now, tomorrow, freq='1H')
r.tz = UTC
print(r[0])
r.tz = UTCTimezone
print(r[0]) # seg faults

I recon things go wrong when boxing in pandas. This is in C / Cython territory, so lot harder to debug for me.

Anyone ideas on the matter? I'd say Timezone probably behaves a bit different from TimezoneInfo but I really don't know where to start. I haven't even found their respective use cases yet.

Versions used:

  • pendulum==1.2.4
  • pandas==0.20.2
  • numpy==1.13.0

I'm running on Fedora Linux.

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions