Series.apply fails when the series is a timezone aware datetime · Issue #25959 · pandas-dev/pandas (original) (raw)

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.