Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
goriccardo opened this issue Apr 2, 2019 · 4 comments · Fixed by #25964
Closed

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

goriccardo opened this issue Apr 2, 2019 · 4 comments · Fixed by #25964
Labels
Bug Regression Functionality that used to work in a prior pandas version Timezones Timezone data dtype
Milestone

Comments

@goriccardo
Copy link

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.

@ThomasKluiters
Copy link
Contributor

I'd like to pick this up as my first issue to contribute to this repo :)

@jbrockmendel
Copy link
Member

One more reason EAs should have “tolist” cc @jreback @jorisvandenbossche

@ThomasKluiters
Copy link
Contributor

Then would the better fix be to just implement tolist for extension arrays?

@jbrockmendel
Copy link
Member

Implementing tolist can wait for now.

@jorisvandenbossche jorisvandenbossche added the Regression Functionality that used to work in a prior pandas version label Apr 3, 2019
@jreback jreback added this to the 0.25.0 milestone Apr 4, 2019
@jreback jreback modified the milestones: 0.25.0, Contributions Welcome May 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Regression Functionality that used to work in a prior pandas version Timezones Timezone data dtype
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants