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

DEPR: DateOffset.apply and DateOffset.apply_index #34580

Closed
jreback opened this issue Jun 4, 2020 · 7 comments · Fixed by #35165
Closed

DEPR: DateOffset.apply and DateOffset.apply_index #34580

jreback opened this issue Jun 4, 2020 · 7 comments · Fixed by #35165
Labels
Deprecate Functionality to remove in pandas Frequency DateOffsets
Milestone

Comments

@jreback
Copy link
Contributor

jreback commented Jun 4, 2020

In [1]: import pandas as pd

In [2]: rng = pd.date_range(start="1/1/2000", periods=10, freq="T")

In [3]: pd.offsets.YearEnd()
Out[3]: <YearEnd: month=12>

In [4]: pd.offsets.YearEnd().apply_index(rng)
Out[4]:
DatetimeIndex(['2000-12-31 00:00:00', '2000-12-31 00:01:00',
               '2000-12-31 00:02:00', '2000-12-31 00:03:00',
               '2000-12-31 00:04:00', '2000-12-31 00:05:00',
               '2000-12-31 00:06:00', '2000-12-31 00:07:00',
               '2000-12-31 00:08:00', '2000-12-31 00:09:00'],
              dtype='datetime64[ns]', freq='T')

In [5]: pd.__version__
Out[5]: '1.0.4'

vs

In [1]: import pandas as pd

In [2]: rng = pd.date_range(start="1/1/2000", periods=10, freq="T")

In [3]: pd.offsets.YearEnd().apply_index(rng)
Out[3]:
array([978220800000000000, 978220860000000000, 978220920000000000,
       978220980000000000, 978221040000000000, 978221100000000000,
       978221160000000000, 978221220000000000, 978221280000000000,
       978221340000000000])

In [4]: pd.__version__
Out[4]: '1.1.0.dev0+2021.g74538104bc'

see #34579 (comment)

errors are here: #33962 (comment)

these don't need to be exposed to users and we should deprecate; it seems that in the offsets reorg some of the offsets Month? are no longer exposing these methods as well (so need to test).

               Traceback (most recent call last):
                 File "/home/runner/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/asv/benchmark.py", line 1184, in main_run_server
                   main_run(run_args)
                 File "/home/runner/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/asv/benchmark.py", line 1058, in main_run
                   result = benchmark.do_run()
                 File "/home/runner/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/asv/benchmark.py", line 537, in do_run
                   return self.run(*self._current_params)
                 File "/home/runner/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/asv/benchmark.py", line 627, in run
                   samples, number = self.benchmark_timing(timer, min_repeat, max_repeat,
                 File "/home/runner/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/asv/benchmark.py", line 694, in benchmark_timing
                   timing = timer.timeit(number)
                 File "/home/runner/miniconda3/envs/pandas-dev/lib/python3.8/timeit.py", line 177, in timeit
                   timing = self.inner(it, self.timer)
                 File "<timeit-src>", line 6, in inner
                 File "/home/runner/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/asv/benchmark.py", line 599, in <lambda>
                   func = lambda: self.func(*param)
                 File "/home/runner/work/pandas/pandas/asv_bench/benchmarks/arithmetic.py", line 469, in time_apply_index
                   offset.apply_index(self.rng)
                 File "pandas/_libs/tslibs/offsets.pyx", line 87, in pandas._libs.tslibs.offsets.apply_index_wraps.wrapper
                 File "pandas/_libs/tslibs/offsets.pyx", line 1397, in pandas._libs.tslibs.offsets.BusinessDay.apply_index
               AttributeError: 'PeriodIndex' object has no attribute '_addsub_int_array'
               
               For parameters: <SemiMonthEnd: day_of_month=15>
               Traceback (most recent call last):
                 File "/home/runner/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/asv/benchmark.py", line 1184, in main_run_server
                   main_run(run_args)
                 File "/home/runner/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/asv/benchmark.py", line 1058, in main_run
                   result = benchmark.do_run()
                 File "/home/runner/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/asv/benchmark.py", line 537, in do_run
                   return self.run(*self._current_params)
                 File "/home/runner/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/asv/benchmark.py", line 627, in run
                   samples, number = self.benchmark_timing(timer, min_repeat, max_repeat,
                 File "/home/runner/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/asv/benchmark.py", line 694, in benchmark_timing
                   timing = timer.timeit(number)
                 File "/home/runner/miniconda3/envs/pandas-dev/lib/python3.8/timeit.py", line 177, in timeit
                   timing = self.inner(it, self.timer)
                 File "<timeit-src>", line 6, in inner
                 File "/home/runner/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/asv/benchmark.py", line 599, in <lambda>
                   func = lambda: self.func(*param)
                 File "/home/runner/work/pandas/pandas/asv_bench/benchmarks/arithmetic.py", line 469, in time_apply_index
                   offset.apply_index(self.rng)
                 File "pandas/_libs/tslibs/offsets.pyx", line 87, in pandas._libs.tslibs.offsets.apply_index_wraps.wrapper
                 File "pandas/_libs/tslibs/offsets.pyx", line 2319, in pandas._libs.tslibs.offsets.SemiMonthOffset.apply_index
               AttributeError: 'PeriodIndex' object has no attribute '_addsub_int_array'
               
               For parameters: <SemiMonthBegin: day_of_month=15>
               Traceback (most recent call last):
                 File "/home/runner/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/asv/benchmark.py", line 1184, in main_run_server
                   main_run(run_args)
                 File "/home/runner/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/asv/benchmark.py", line 1058, in main_run
                   result = benchmark.do_run()
                 File "/home/runner/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/asv/benchmark.py", line 537, in do_run
                   return self.run(*self._current_params)
                 File "/home/runner/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/asv/benchmark.py", line 627, in run
                   samples, number = self.benchmark_timing(timer, min_repeat, max_repeat,
                 File "/home/runner/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/asv/benchmark.py", line 694, in benchmark_timing
                   timing = timer.timeit(number)
                 File "/home/runner/miniconda3/envs/pandas-dev/lib/python3.8/timeit.py", line 177, in timeit
                   timing = self.inner(it, self.timer)
                 File "<timeit-src>", line 6, in inner
                 File "/home/runner/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/asv/benchmark.py", line 599, in <lambda>
                   func = lambda: self.func(*param)
                 File "/home/runner/work/pandas/pandas/asv_bench/benchmarks/arithmetic.py", line 469, in time_apply_index
                   offset.apply_index(self.rng)
                 File "pandas/_libs/tslibs/offsets.pyx", line 87, in pandas._libs.tslibs.offsets.apply_index_wraps.wrapper
                 File "pandas/_libs/tslibs/offsets.pyx", line 2319, in pandas._libs.tslibs.offsets.SemiMonthOffset.apply_index
               AttributeError: 'PeriodIndex' object has no attribute '_addsub_int_array'
@jreback jreback added Frequency DateOffsets Deprecate Functionality to remove in pandas labels Jun 4, 2020
@jreback jreback added this to the 1.1 milestone Jun 4, 2020
@jreback
Copy link
Contributor Author

jreback commented Jun 4, 2020

cc @jbrockmendel

@jorisvandenbossche
Copy link
Member

Do we also not have to fix the failure? (in addition to deprecating)

@hasnain2808
Copy link
Contributor

hasnain2808 commented Jun 4, 2020

@jorisvandenbossche
#34579 fixed that ci failure short term

@jreback
Copy link
Contributor Author

jreback commented Jun 4, 2020

yes that’s i the comments too

@jorisvandenbossche
Copy link
Member

That fixed CI by removing the usage, it didn't fix the actual use case

@jreback
Copy link
Contributor Author

jreback commented Jun 4, 2020

correct that’s what this issue is about

@TomAugspurger
Copy link
Contributor

Added an example to the original post. Will take a look sometime in the next couple days.

TomAugspurger added a commit to TomAugspurger/pandas that referenced this issue Jul 7, 2020
TomAugspurger added a commit to TomAugspurger/pandas that referenced this issue Jul 7, 2020
TomAugspurger added a commit to TomAugspurger/pandas that referenced this issue Jul 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecate Functionality to remove in pandas Frequency DateOffsets
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants