Skip to content

Series.apply fails when the series is a timezone aware datetime #25959

Closed
@goriccardo

Description

@goriccardo

To reproduce the problem:

import pandas as pd

s = pd.util.testing.makeTimeSeries()
s = s.tz_localize('UTC')
pd.Series(s.index).apply(lambda x: pd.Series([1,2]))

AttributeError: 'PandasArray' object has no attribute 'tolist'

It works fine if the function to apply returns a scalar instead of a Series:

import pandas as pd

s = pd.util.testing.makeTimeSeries()
s = s.tz_localize('UTC')
pd.Series(s.index).apply(lambda x: 1)

or it there is no timezone information in the series.

import pandas as pd

s = pd.util.testing.makeTimeSeries()
pd.Series(s.index).apply(lambda x: pd.Series([1,2]))

The issue is present with pandas 0.24.2, it used to work fine with 0.23.4.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugRegressionFunctionality that used to work in a prior pandas versionTimezonesTimezone data dtype

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions