Skip to content

[Python] support dateutil timezones  #26863

@asfimport

Description

@asfimport

Here are two main reasons:

  1. As of Python 3.6, the tzinfo documentation  recommends dateutil.tz rather than pytz as an IANA time zone provider.

  2. Pandas supports dateutil timezones.

    When having a pandas DataFrame that uses a dateutil timezone,  you get an error. 

    Below is a code sample:

    import dateutil
    tz = dateutil.tz.gettz('Asia/Shanghai')
    df = pd.DataFrame({'a': list(range(1, 4)), 'b': pd.date_range('20130101', periods=3, tz=tz)})
    df.to_feather('df.feather')

    Errors:

    ArrowInvalid: ('Object returned by tzinfo.utcoffset(None) is not an instance of datetime.timedelta', "Conversion failed for column b with type datetime64[ns, tzfile('/usr/share/zoneinfo/Asia/Shanghai')]")

     

Reporter: Eric Du

Related issues:

Note: This issue was originally created as ARROW-10936. Please see the migration documentation for further details.

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