-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Unexpected result with Resampler.apply for non-naive time index #25411
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
Comments
there was quite a bit of work on this in 0.24 |
I get the same result with pandas 0.24.1 |
It seems like the index of data is made naive by Resampler.apply when passing it to the custom function. |
The output in pandas 1.0.1 is:
So, this issue has been resolved by now! |
I am having this same problem in 1.0.1. If I do the following def show_tz(xs):
print(xs.index.tz)
return False
ser = pd.Series(
1,
index=pd.date_range(
start='2020-01-01',
end='2020-01-05',
freq='H',
tz='Etc/GMT-7'
)
)
ser.resample('D').apply(show_tz) I expect to see the following output
But instead I get
If you examine the value of |
As of pandas version 1.3.5, this issue is no longer present. Seems to be solved since version 1.3.3. With version 1.3.2 I get a IndexError when executing above example. |
would certainly take a validation test for this |
When resampling a non-naive time series with a custom function (using apply or agg), an unexpected result is returned.
Expected Output
The (single) value of the series should correspond with:
One indeed gets this result when passing
data
andweigths
with naive time index:But, as shown above, not when passing non-naive time series.
Output of
pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.6.6.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 78 Stepping 3, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None
pandas: 0.23.4
pytest: 4.2.1
pip: 19.0.2
setuptools: 39.0.1
Cython: 0.29.4
numpy: 1.16.0
scipy: 1.2.0
pyarrow: None
xarray: 0.11.3
IPython: 7.2.0
sphinx: None
patsy: 0.5.1
dateutil: 2.7.5
pytz: 2018.9
blosc: None
bottleneck: 1.2.1
tables: None
numexpr: None
feather: None
matplotlib: 2.2.3
openpyxl: 2.5.12
xlrd: 1.2.0
xlwt: 1.3.0
xlsxwriter: 1.1.2
lxml: 4.3.0
bs4: 4.6.1
html5lib: 1.0.1
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: