Skip to content

Commit bb2fdd7

Browse files
Merge branch 'main' into plot
2 parents 16762b6 + 1bcdfd0 commit bb2fdd7

File tree

6 files changed

+90
-11
lines changed

6 files changed

+90
-11
lines changed

ci/code_checks.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
7272
-i "pandas.Series.dt PR01" `# Accessors are implemented as classes, but we do not document the Parameters section` \
7373
-i "pandas.Period.freq GL08" \
7474
-i "pandas.Period.ordinal GL08" \
75-
-i "pandas.Timestamp.max PR02" \
76-
-i "pandas.Timestamp.min PR02" \
77-
-i "pandas.Timestamp.resolution PR02" \
7875
-i "pandas.core.groupby.DataFrameGroupBy.plot PR02" \
7976
-i "pandas.core.groupby.SeriesGroupBy.plot PR02" \
8077
-i "pandas.core.resample.Resampler.quantile PR01,PR07" \

doc/source/whatsnew/v3.0.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,7 @@ Groupby/resample/rolling
774774
- Bug in :meth:`.DataFrameGroupBy.quantile` when ``interpolation="nearest"`` is inconsistent with :meth:`DataFrame.quantile` (:issue:`47942`)
775775
- Bug in :meth:`.Resampler.interpolate` on a :class:`DataFrame` with non-uniform sampling and/or indices not aligning with the resulting resampled index would result in wrong interpolation (:issue:`21351`)
776776
- Bug in :meth:`DataFrame.ewm` and :meth:`Series.ewm` when passed ``times`` and aggregation functions other than mean (:issue:`51695`)
777+
- Bug in :meth:`DataFrame.resample` and :meth:`Series.resample` were not keeping the index name when the index had :class:`ArrowDtype` timestamp dtype (:issue:`61222`)
777778
- Bug in :meth:`DataFrame.resample` changing index type to :class:`MultiIndex` when the dataframe is empty and using an upsample method (:issue:`55572`)
778779
- Bug in :meth:`DataFrameGroupBy.agg` that raises ``AttributeError`` when there is dictionary input and duplicated columns, instead of returning a DataFrame with the aggregation of all duplicate columns. (:issue:`55041`)
779780
- Bug in :meth:`DataFrameGroupBy.apply` and :meth:`SeriesGroupBy.apply` for empty data frame with ``group_keys=False`` still creating output index using group keys. (:issue:`60471`)

pandas/_libs/tslibs/timestamps.pyx

Lines changed: 77 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,9 @@ class MinMaxReso:
200200
201201
See also: timedeltas.MinMaxReso
202202
"""
203-
def __init__(self, name):
203+
def __init__(self, name, docstring):
204204
self._name = name
205+
self.__doc__ = docstring
205206

206207
def __get__(self, obj, type=None):
207208
cls = Timestamp
@@ -216,11 +217,15 @@ class MinMaxReso:
216217

217218
if obj is None:
218219
# i.e. this is on the class, default to nanos
219-
return cls(val)
220+
result = cls(val)
220221
elif self._name == "resolution":
221-
return Timedelta._from_value_and_reso(val, obj._creso)
222+
result = Timedelta._from_value_and_reso(val, obj._creso)
222223
else:
223-
return Timestamp._from_value_and_reso(val, obj._creso, tz=None)
224+
result = Timestamp._from_value_and_reso(val, obj._creso, tz=None)
225+
226+
result.__doc__ = self.__doc__
227+
228+
return result
224229

225230
def __set__(self, obj, value):
226231
raise AttributeError(f"{self._name} is not settable.")
@@ -235,9 +240,74 @@ cdef class _Timestamp(ABCTimestamp):
235240
dayofweek = _Timestamp.day_of_week
236241
dayofyear = _Timestamp.day_of_year
237242

238-
min = MinMaxReso("min")
239-
max = MinMaxReso("max")
240-
resolution = MinMaxReso("resolution") # GH#21336, GH#21365
243+
_docstring_min = """
244+
Returns the minimum bound possible for Timestamp.
245+
246+
This property provides access to the smallest possible value that
247+
can be represented by a Timestamp object.
248+
249+
Returns
250+
-------
251+
Timestamp
252+
253+
See Also
254+
--------
255+
Timestamp.max: Returns the maximum bound possible for Timestamp.
256+
Timestamp.resolution: Returns the smallest possible difference between
257+
non-equal Timestamp objects.
258+
259+
Examples
260+
--------
261+
>>> pd.Timestamp.min
262+
Timestamp('1677-09-21 00:12:43.145224193')
263+
"""
264+
265+
_docstring_max = """
266+
Returns the maximum bound possible for Timestamp.
267+
268+
This property provides access to the largest possible value that
269+
can be represented by a Timestamp object.
270+
271+
Returns
272+
-------
273+
Timestamp
274+
275+
See Also
276+
--------
277+
Timestamp.min: Returns the minimum bound possible for Timestamp.
278+
Timestamp.resolution: Returns the smallest possible difference between
279+
non-equal Timestamp objects.
280+
281+
Examples
282+
--------
283+
>>> pd.Timestamp.max
284+
Timestamp('2262-04-11 23:47:16.854775807')
285+
"""
286+
287+
_docstring_reso = """
288+
Returns the smallest possible difference between non-equal Timestamp objects.
289+
290+
The resolution value is determined by the underlying representation of time
291+
units and is equivalent to Timedelta(nanoseconds=1).
292+
293+
Returns
294+
-------
295+
Timedelta
296+
297+
See Also
298+
--------
299+
Timestamp.max: Returns the maximum bound possible for Timestamp.
300+
Timestamp.min: Returns the minimum bound possible for Timestamp.
301+
302+
Examples
303+
--------
304+
>>> pd.Timestamp.resolution
305+
Timedelta('0 days 00:00:00.000000001')
306+
"""
307+
308+
min = MinMaxReso("min", _docstring_min)
309+
max = MinMaxReso("max", _docstring_max)
310+
resolution = MinMaxReso("resolution", _docstring_reso) # GH#21336, GH#21365
241311

242312
@property
243313
def value(self) -> int:

pandas/core/resample.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ def _wrap_result(self, result):
518518

519519
if self._timegrouper._arrow_dtype is not None:
520520
result.index = result.index.astype(self._timegrouper._arrow_dtype)
521+
result.index.name = self.obj.index.name
521522

522523
return result
523524

pandas/tests/resample/test_datetime_index.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,6 +2155,16 @@ def test_arrow_timestamp_resample(tz):
21552155
tm.assert_series_equal(result, expected)
21562156

21572157

2158+
@td.skip_if_no("pyarrow")
2159+
def test_arrow_timestamp_resample_keep_index_name():
2160+
# https://github.com/pandas-dev/pandas/issues/61222
2161+
idx = Series(date_range("2020-01-01", periods=5), dtype="timestamp[ns][pyarrow]")
2162+
expected = Series(np.arange(5, dtype=np.float64), index=idx)
2163+
expected.index.name = "index_name"
2164+
result = expected.resample("1D").mean()
2165+
tm.assert_series_equal(result, expected)
2166+
2167+
21582168
@pytest.mark.parametrize("freq", ["1A", "2A-MAR"])
21592169
def test_resample_A_raises(freq):
21602170
msg = f"Invalid frequency: {freq[1:]}"

web/pandas/community/ecosystem.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ Pandas provides an interface for defining
655655
The following libraries implement that interface to provide types not found in NumPy or pandas,
656656
which work well with pandas' data containers.
657657

658-
### [awkward-pandas](https://awkward-pandas.readthedocs.io/)
658+
### [awkward-pandas](https://github.com/scikit-hep/awkward)
659659

660660
Awkward-pandas provides an extension type for storing [Awkward
661661
Arrays](https://awkward-array.org/) inside pandas' Series and

0 commit comments

Comments
 (0)