Skip to content

Commit 55a4b19

Browse files
Merge branch 'main' into np-doc-ts-asunit
2 parents 0c9bcde + a22073c commit 55a4b19

15 files changed

+55
-74
lines changed

doc/source/whatsnew/v3.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ Removal of prior version deprecations/changes
254254
- Enforced deprecation of :meth:`offsets.Tick.delta`, use ``pd.Timedelta(obj)`` instead (:issue:`55498`)
255255
- Enforced deprecation of ``axis=None`` acting the same as ``axis=0`` in the DataFrame reductions ``sum``, ``prod``, ``std``, ``var``, and ``sem``, passing ``axis=None`` will now reduce over both axes; this is particularly the case when doing e.g. ``numpy.sum(df)`` (:issue:`21597`)
256256
- Enforced deprecation of ``core.internals`` members ``Block``, ``ExtensionBlock``, and ``DatetimeTZBlock`` (:issue:`58467`)
257+
- Enforced deprecation of ``quantile`` keyword in :meth:`.Rolling.quantile` and :meth:`.Expanding.quantile`, renamed to ``q`` instead. (:issue:`52550`)
257258
- Enforced deprecation of non-standard (``np.ndarray``, :class:`ExtensionArray`, :class:`Index`, or :class:`Series`) argument to :func:`api.extensions.take` (:issue:`52981`)
258259
- Enforced deprecation of parsing system timezone strings to ``tzlocal``, which depended on system timezone, pass the 'tz' keyword instead (:issue:`50791`)
259260
- Enforced deprecation of passing a dictionary to :meth:`SeriesGroupBy.agg` (:issue:`52268`)

pandas/conftest.py

+26-26
Original file line numberDiff line numberDiff line change
@@ -672,47 +672,47 @@ def _create_mi_with_dt64tz_level():
672672

673673

674674
indices_dict = {
675-
"string": Index([f"pandas_{i}" for i in range(100)]),
676-
"datetime": date_range("2020-01-01", periods=100),
677-
"datetime-tz": date_range("2020-01-01", periods=100, tz="US/Pacific"),
678-
"period": period_range("2020-01-01", periods=100, freq="D"),
679-
"timedelta": timedelta_range(start="1 day", periods=100, freq="D"),
680-
"range": RangeIndex(100),
681-
"int8": Index(np.arange(100), dtype="int8"),
682-
"int16": Index(np.arange(100), dtype="int16"),
683-
"int32": Index(np.arange(100), dtype="int32"),
684-
"int64": Index(np.arange(100), dtype="int64"),
685-
"uint8": Index(np.arange(100), dtype="uint8"),
686-
"uint16": Index(np.arange(100), dtype="uint16"),
687-
"uint32": Index(np.arange(100), dtype="uint32"),
688-
"uint64": Index(np.arange(100), dtype="uint64"),
689-
"float32": Index(np.arange(100), dtype="float32"),
690-
"float64": Index(np.arange(100), dtype="float64"),
675+
"string": Index([f"pandas_{i}" for i in range(10)]),
676+
"datetime": date_range("2020-01-01", periods=10),
677+
"datetime-tz": date_range("2020-01-01", periods=10, tz="US/Pacific"),
678+
"period": period_range("2020-01-01", periods=10, freq="D"),
679+
"timedelta": timedelta_range(start="1 day", periods=10, freq="D"),
680+
"range": RangeIndex(10),
681+
"int8": Index(np.arange(10), dtype="int8"),
682+
"int16": Index(np.arange(10), dtype="int16"),
683+
"int32": Index(np.arange(10), dtype="int32"),
684+
"int64": Index(np.arange(10), dtype="int64"),
685+
"uint8": Index(np.arange(10), dtype="uint8"),
686+
"uint16": Index(np.arange(10), dtype="uint16"),
687+
"uint32": Index(np.arange(10), dtype="uint32"),
688+
"uint64": Index(np.arange(10), dtype="uint64"),
689+
"float32": Index(np.arange(10), dtype="float32"),
690+
"float64": Index(np.arange(10), dtype="float64"),
691691
"bool-object": Index([True, False] * 5, dtype=object),
692692
"bool-dtype": Index([True, False] * 5, dtype=bool),
693693
"complex64": Index(
694-
np.arange(100, dtype="complex64") + 1.0j * np.arange(100, dtype="complex64")
694+
np.arange(10, dtype="complex64") + 1.0j * np.arange(10, dtype="complex64")
695695
),
696696
"complex128": Index(
697-
np.arange(100, dtype="complex128") + 1.0j * np.arange(100, dtype="complex128")
697+
np.arange(10, dtype="complex128") + 1.0j * np.arange(10, dtype="complex128")
698698
),
699-
"categorical": CategoricalIndex(list("abcd") * 25),
700-
"interval": IntervalIndex.from_breaks(np.linspace(0, 100, num=101)),
699+
"categorical": CategoricalIndex(list("abcd") * 2),
700+
"interval": IntervalIndex.from_breaks(np.linspace(0, 100, num=11)),
701701
"empty": Index([]),
702702
"tuples": MultiIndex.from_tuples(zip(["foo", "bar", "baz"], [1, 2, 3])),
703703
"mi-with-dt64tz-level": _create_mi_with_dt64tz_level(),
704704
"multi": _create_multiindex(),
705705
"repeats": Index([0, 0, 1, 1, 2, 2]),
706-
"nullable_int": Index(np.arange(100), dtype="Int64"),
707-
"nullable_uint": Index(np.arange(100), dtype="UInt16"),
708-
"nullable_float": Index(np.arange(100), dtype="Float32"),
709-
"nullable_bool": Index(np.arange(100).astype(bool), dtype="boolean"),
706+
"nullable_int": Index(np.arange(10), dtype="Int64"),
707+
"nullable_uint": Index(np.arange(10), dtype="UInt16"),
708+
"nullable_float": Index(np.arange(10), dtype="Float32"),
709+
"nullable_bool": Index(np.arange(10).astype(bool), dtype="boolean"),
710710
"string-python": Index(
711-
pd.array([f"pandas_{i}" for i in range(100)], dtype="string[python]")
711+
pd.array([f"pandas_{i}" for i in range(10)], dtype="string[python]")
712712
),
713713
}
714714
if has_pyarrow:
715-
idx = Index(pd.array([f"pandas_{i}" for i in range(100)], dtype="string[pyarrow]"))
715+
idx = Index(pd.array([f"pandas_{i}" for i in range(10)], dtype="string[pyarrow]"))
716716
indices_dict["string-pyarrow"] = idx
717717

718718

pandas/core/window/expanding.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88
Literal,
99
)
1010

11-
from pandas.util._decorators import (
12-
deprecate_kwarg,
13-
doc,
14-
)
11+
from pandas.util._decorators import doc
1512

1613
from pandas.core.indexers.objects import (
1714
BaseIndexer,
@@ -709,7 +706,6 @@ def kurt(self, numeric_only: bool = False):
709706
aggregation_description="quantile",
710707
agg_method="quantile",
711708
)
712-
@deprecate_kwarg(old_arg_name="quantile", new_arg_name="q")
713709
def quantile(
714710
self,
715711
q: float,

pandas/core/window/rolling.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@
2727
import pandas._libs.window.aggregations as window_aggregations
2828
from pandas.compat._optional import import_optional_dependency
2929
from pandas.errors import DataError
30-
from pandas.util._decorators import (
31-
deprecate_kwarg,
32-
doc,
33-
)
30+
from pandas.util._decorators import doc
3431

3532
from pandas.core.dtypes.common import (
3633
ensure_float64,
@@ -2556,7 +2553,6 @@ def kurt(self, numeric_only: bool = False):
25562553
aggregation_description="quantile",
25572554
agg_method="quantile",
25582555
)
2559-
@deprecate_kwarg(old_arg_name="quantile", new_arg_name="q")
25602556
def quantile(
25612557
self,
25622558
q: float,

pandas/tests/frame/conftest.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ def datetime_frame() -> DataFrame:
1717
Columns are ['A', 'B', 'C', 'D']
1818
"""
1919
return DataFrame(
20-
np.random.default_rng(2).standard_normal((100, 4)),
20+
np.random.default_rng(2).standard_normal((10, 4)),
2121
columns=Index(list("ABCD"), dtype=object),
22-
index=date_range("2000-01-01", periods=100, freq="B"),
22+
index=date_range("2000-01-01", periods=10, freq="B"),
2323
)
2424

2525

pandas/tests/frame/indexing/test_indexing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def test_setitem_list2(self):
118118

119119
def test_getitem_boolean(self, mixed_float_frame, mixed_int_frame, datetime_frame):
120120
# boolean indexing
121-
d = datetime_frame.index[10]
121+
d = datetime_frame.index[len(datetime_frame) // 2]
122122
indexer = datetime_frame.index > d
123123
indexer_obj = indexer.astype(object)
124124

pandas/tests/frame/methods/test_at_time.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def test_at_time_raises(self, frame_or_series):
9797

9898
def test_at_time_axis(self, axis):
9999
# issue 8839
100-
rng = date_range("1/1/2000", "1/5/2000", freq="5min")
100+
rng = date_range("1/1/2000", "1/2/2000", freq="5min")
101101
ts = DataFrame(np.random.default_rng(2).standard_normal((len(rng), len(rng))))
102102
ts.index, ts.columns = rng, rng
103103

pandas/tests/frame/methods/test_cov_corr.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ def test_corrwith(self, datetime_frame, dtype):
285285
b = datetime_frame.add(noise, axis=0)
286286

287287
# make sure order does not matter
288-
b = b.reindex(columns=b.columns[::-1], index=b.index[::-1][10:])
288+
b = b.reindex(columns=b.columns[::-1], index=b.index[::-1][len(a) // 2 :])
289289
del b["B"]
290290

291291
colcorr = a.corrwith(b, axis=0)
@@ -301,7 +301,7 @@ def test_corrwith(self, datetime_frame, dtype):
301301
dropped = a.corrwith(b, axis=1, drop=True)
302302
assert a.index[-1] not in dropped.index
303303

304-
# non time-series data
304+
def test_corrwith_non_timeseries_data(self):
305305
index = ["a", "b", "c", "d", "e"]
306306
columns = ["one", "two", "three", "four"]
307307
df1 = DataFrame(

pandas/tests/frame/methods/test_fillna.py

-3
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ def test_fillna_datetime(self, datetime_frame):
6060

6161
padded = datetime_frame.ffill()
6262
assert np.isnan(padded.loc[padded.index[:5], "A"]).all()
63-
assert (
64-
padded.loc[padded.index[-5:], "A"] == padded.loc[padded.index[-5], "A"]
65-
).all()
6663

6764
msg = r"missing 1 required positional argument: 'value'"
6865
with pytest.raises(TypeError, match=msg):

pandas/tests/frame/methods/test_to_csv.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def read_csv(self, path, **kwargs):
3333

3434
return read_csv(path, **params)
3535

36-
def test_to_csv_from_csv1(self, temp_file, float_frame, datetime_frame):
36+
def test_to_csv_from_csv1(self, temp_file, float_frame):
3737
path = str(temp_file)
3838
float_frame.iloc[:5, float_frame.columns.get_loc("A")] = np.nan
3939

@@ -42,6 +42,8 @@ def test_to_csv_from_csv1(self, temp_file, float_frame, datetime_frame):
4242
float_frame.to_csv(path, header=False)
4343
float_frame.to_csv(path, index=False)
4444

45+
def test_to_csv_from_csv1_datetime(self, temp_file, datetime_frame):
46+
path = str(temp_file)
4547
# test roundtrip
4648
# freq does not roundtrip
4749
datetime_frame.index = datetime_frame.index._with_freq(None)
@@ -59,7 +61,8 @@ def test_to_csv_from_csv1(self, temp_file, float_frame, datetime_frame):
5961
recons = self.read_csv(path, index_col=None, parse_dates=True)
6062
tm.assert_almost_equal(datetime_frame.values, recons.values)
6163

62-
# corner case
64+
def test_to_csv_from_csv1_corner_case(self, temp_file):
65+
path = str(temp_file)
6366
dm = DataFrame(
6467
{
6568
"s1": Series(range(3), index=np.arange(3, dtype=np.int64)),
@@ -1167,9 +1170,16 @@ def test_to_csv_with_dst_transitions(self, td, temp_file):
11671170
result.index = to_datetime(result.index, utc=True).tz_convert("Europe/London")
11681171
tm.assert_frame_equal(result, df)
11691172

1170-
def test_to_csv_with_dst_transitions_with_pickle(self, temp_file):
1173+
@pytest.mark.parametrize(
1174+
"start,end",
1175+
[
1176+
["2015-03-29", "2015-03-30"],
1177+
["2015-10-25", "2015-10-26"],
1178+
],
1179+
)
1180+
def test_to_csv_with_dst_transitions_with_pickle(self, start, end, temp_file):
11711181
# GH11619
1172-
idx = date_range("2015-01-01", "2015-12-31", freq="h", tz="Europe/Paris")
1182+
idx = date_range(start, end, freq="h", tz="Europe/Paris")
11731183
idx = idx._with_freq(None) # freq does not round-trip
11741184
idx._data._freq = None # otherwise there is trouble on unpickle
11751185
df = DataFrame({"values": 1, "idx": idx}, index=idx)

pandas/tests/frame/methods/test_truncate.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def test_truncate(self, datetime_frame, frame_or_series):
6060
truncated = ts.truncate(before=ts.index[-1] + ts.index.freq)
6161
assert len(truncated) == 0
6262

63-
msg = "Truncate: 2000-01-06 00:00:00 must be after 2000-05-16 00:00:00"
63+
msg = "Truncate: 2000-01-06 00:00:00 must be after 2000-01-11 00:00:00"
6464
with pytest.raises(ValueError, match=msg):
6565
ts.truncate(
6666
before=ts.index[-1] - ts.index.freq, after=ts.index[0] + ts.index.freq

pandas/tests/frame/test_block_internals.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -249,20 +249,19 @@ def f(dtype):
249249
with pytest.raises(ValueError, match=msg):
250250
f("M8[ns]")
251251

252-
def test_pickle(self, float_string_frame, timezone_frame):
253-
empty_frame = DataFrame()
254-
252+
def test_pickle_float_string_frame(self, float_string_frame):
255253
unpickled = tm.round_trip_pickle(float_string_frame)
256254
tm.assert_frame_equal(float_string_frame, unpickled)
257255

258256
# buglet
259257
float_string_frame._mgr.ndim
260258

261-
# empty
259+
def test_pickle_empty(self):
260+
empty_frame = DataFrame()
262261
unpickled = tm.round_trip_pickle(empty_frame)
263262
repr(unpickled)
264263

265-
# tz frame
264+
def test_pickle_empty_tz_frame(self, timezone_frame):
266265
unpickled = tm.round_trip_pickle(timezone_frame)
267266
tm.assert_frame_equal(timezone_frame, unpickled)
268267

pandas/tests/frame/test_constructors.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2280,7 +2280,7 @@ def test_check_dtype_empty_numeric_column(self, dtype):
22802280
@pytest.mark.parametrize(
22812281
"dtype", tm.STRING_DTYPES + tm.BYTES_DTYPES + tm.OBJECT_DTYPES
22822282
)
2283-
def test_check_dtype_empty_string_column(self, request, dtype):
2283+
def test_check_dtype_empty_string_column(self, dtype):
22842284
# GH24386: Ensure dtypes are set correctly for an empty DataFrame.
22852285
# Empty DataFrame is generated via dictionary data with non-overlapping columns.
22862286
data = DataFrame({"a": [1, 2]}, columns=["b"], dtype=dtype)

pandas/tests/window/test_expanding.py

-9
Original file line numberDiff line numberDiff line change
@@ -691,12 +691,3 @@ def test_numeric_only_corr_cov_series(kernel, use_arg, numeric_only, dtype):
691691
op2 = getattr(expanding2, kernel)
692692
expected = op2(*arg2, numeric_only=numeric_only)
693693
tm.assert_series_equal(result, expected)
694-
695-
696-
def test_keyword_quantile_deprecated():
697-
# GH #52550
698-
ser = Series([1, 2, 3, 4])
699-
with tm.assert_produces_warning(
700-
FutureWarning, match="the 'quantile' keyword is deprecated, use 'q' instead"
701-
):
702-
ser.expanding().quantile(quantile=0.5)

pandas/tests/window/test_rolling_quantile.py

-9
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,3 @@ def test_center_reindex_frame(frame, q):
173173
)
174174
frame_rs = frame.rolling(window=25, center=True).quantile(q)
175175
tm.assert_frame_equal(frame_xp, frame_rs)
176-
177-
178-
def test_keyword_quantile_deprecated():
179-
# GH #52550
180-
s = Series([1, 2, 3, 4])
181-
with tm.assert_produces_warning(
182-
FutureWarning, match="the 'quantile' keyword is deprecated, use 'q' instead"
183-
):
184-
s.rolling(2).quantile(quantile=0.4)

0 commit comments

Comments
 (0)