Repository: pandas-dev/pandas

Issue:
PERF: asvs are failing
This is from a PR recently rebased; I don't think the asv's were run when we merged the ordered deprecation changes

https://dev.azure.com/pandas-dev/pandas/_build/results?buildId=13903

cc @jschendel 


```
[  4.36%] ··· categoricals.Rank.time_rank_string_cat                      failed
[  4.36%] ···· Traceback (most recent call last):
                 File "/home/vsts/miniconda3/envs/pandas-dev/lib/python3.7/site-packages/asv/benchmark.py", line 1184, in main_run_server
                   main_run(run_args)
                 File "/home/vsts/miniconda3/envs/pandas-dev/lib/python3.7/site-packages/asv/benchmark.py", line 1052, in main_run
                   skip = benchmark.do_setup()
                 File "/home/vsts/miniconda3/envs/pandas-dev/lib/python3.7/site-packages/asv/benchmark.py", line 583, in do_setup
                   result = Benchmark.do_setup(self)
                 File "/home/vsts/miniconda3/envs/pandas-dev/lib/python3.7/site-packages/asv/benchmark.py", line 515, in do_setup
                   setup(*self._current_params)
                 File "/home/vsts/work/1/s/asv_bench/benchmarks/categoricals.py", line 138, in setup
                   ordered=True)
                 File "/home/vsts/work/1/s/pandas/core/generic.py", line 5600, in astype
                   **kwargs)
                 File "/home/vsts/work/1/s/pandas/core/internals/managers.py", line 529, in astype
                   return self.apply('astype', dtype=dtype, **kwargs)
                 File "/home/vsts/work/1/s/pandas/core/internals/managers.py", line 393, in apply
                   applied = getattr(b, f)(**kwargs)
                 File "/home/vsts/work/1/s/pandas/core/internals/blocks.py", line 514, in astype
                   **kwargs)
                 File "/home/vsts/work/1/s/pandas/core/internals/blocks.py", line 554, in _astype
                   deprecated_arg))
               ValueError: Got an unexpected argument: ordered
```


Discussion:
There are a couple kinds actually. I can take a look at the tz one.

```
[ 44.54%] ··· ...s.ToDatetimeNONISO8601.time_different_offset             failed
[ 44.54%] ···· Traceback (most recent call last):
                 File "/home/vsts/work/1/s/pandas/core/arrays/datetimes.py", line 1861, in objects_to_datetime64ns
                   values, tz_parsed = conversion.datetime_to_datetime64(data)
                 File "pandas/_libs/tslibs/conversion.pyx", line 185, in pandas._libs.tslibs.conversion.datetime_to_datetime64
               ValueError: Array must be all same time zone
               
               During handling of the above exception, another exception occurred:
               
               Traceback (most recent call last):
                 File "/home/vsts/miniconda3/envs/pandas-dev/lib/python3.7/site-packages/asv/benchmark.py", line 1184, in main_run_server
                   main_run(run_args)
                 File "/home/vsts/miniconda3/envs/pandas-dev/lib/python3.7/site-packages/asv/benchmark.py", line 1058, in main_run
                   result = benchmark.do_run()
                 File "/home/vsts/miniconda3/envs/pandas-dev/lib/python3.7/site-packages/asv/benchmark.py", line 537, in do_run
                   return self.run(*self._current_params)
                 File "/home/vsts/miniconda3/envs/pandas-dev/lib/python3.7/site-packages/asv/benchmark.py", line 631, in run
                   min_run_count=self.min_run_count)
                 File "/home/vsts/miniconda3/envs/pandas-dev/lib/python3.7/site-packages/asv/benchmark.py", line 694, in benchmark_timing
                   timing = timer.timeit(number)
                 File "/home/vsts/miniconda3/envs/pandas-dev/lib/python3.7/timeit.py", line 176, in timeit
                   timing = self.inner(it, self.timer)
                 File "<timeit-src>", line 6, in inner
                 File "/home/vsts/work/1/s/asv_bench/benchmarks/timeseries.py", line 355, in time_different_offset
                   to_datetime(self.diff_offset)
                 File "/home/vsts/work/1/s/pandas/util/_decorators.py", line 188, in wrapper
                   return func(*args, **kwargs)
                 File "/home/vsts/work/1/s/pandas/core/tools/datetimes.py", line 693, in to_datetime
                   result = _convert_and_box_cache(arg, cache_array, box, errors)
                 File "/home/vsts/work/1/s/pandas/core/tools/datetimes.py", line 161, in _convert_and_box_cache
                   return DatetimeIndex(result, name=name)
                 File "/home/vsts/work/1/s/pandas/core/indexes/datetimes.py", line 297, in __new__
                   int_as_wall_time=True)
                 File "/home/vsts/work/1/s/pandas/core/arrays/datetimes.py", line 379, in _from_sequence
                   ambiguous=ambiguous, int_as_wall_time=int_as_wall_time)
                 File "/home/vsts/work/1/s/pandas/core/arrays/datetimes.py", line 1757, in sequence_to_dt64ns
                   data, dayfirst=dayfirst, yearfirst=yearfirst)
                 File "/home/vsts/work/1/s/pandas/core/arrays/datetimes.py", line 1866, in objects_to_datetime64ns
                   raise e
                 File "/home/vsts/work/1/s/pandas/core/arrays/datetimes.py", line 1857, in objects_to_datetime64ns
                   require_iso8601=require_iso8601
                 File "pandas/_libs/tslib.pyx", line 465, in pandas._libs.tslib.array_to_datetime
                 File "pandas/_libs/tslib.pyx", line 543, in pandas._libs.tslib.array_to_datetime
               ValueError: Tz-aware datetime.datetime cannot be converted to datetime64 unless utc=True
```
The `ordered` failures are from https://github.com/pandas-dev/pandas/issues/17742 (removing `ordered` from `.astype`). Just need to update for that removal. Will send a PR.

Resolving patch:
diff --git a/asv_bench/benchmarks/categoricals.py b/asv_bench/benchmarks/categoricals.py
--- a/asv_bench/benchmarks/categoricals.py
+++ b/asv_bench/benchmarks/categoricals.py
@@ -1,5 +1,3 @@
-import warnings
-
 import numpy as np
 import pandas as pd
 import pandas.util.testing as tm
@@ -133,15 +131,10 @@ def setup(self):
 
         self.s_str = pd.Series(tm.makeCategoricalIndex(N, ncats)).astype(str)
         self.s_str_cat = self.s_str.astype('category')
-        with warnings.catch_warnings(record=True):
-            self.s_str_cat_ordered = self.s_str.astype('category',
-                                                       ordered=True)
-
+        self.s_str_cat_ordered = self.s_str_cat.cat.as_ordered()
         self.s_int = pd.Series(np.random.randint(0, ncats, size=N))
         self.s_int_cat = self.s_int.astype('category')
-        with warnings.catch_warnings(record=True):
-            self.s_int_cat_ordered = self.s_int.astype('category',
-                                                       ordered=True)
+        self.s_int_cat_ordered = self.s_int_cat.cat.as_ordered()
 
     def time_rank_string(self):
         self.s_str.rank()


Test patch: