Skip to content

Commit fe52a7a

Browse files
Merge branch 'main' into fix-59242
2 parents bcb7e3d + e557039 commit fe52a7a

File tree

14 files changed

+54
-26
lines changed

14 files changed

+54
-26
lines changed

doc/source/user_guide/groupby.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ You can also include the grouping columns if you want to operate on them.
418418
419419
.. note::
420420

421-
The ``groupby`` operation in Pandas drops the ``name`` field of the columns Index object
421+
The ``groupby`` operation in pandas drops the ``name`` field of the columns Index object
422422
after the operation. This change ensures consistency in syntax between different
423423
column selection methods within groupby operations.
424424

doc/source/user_guide/io.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ Thousand separators
990990

991991
For large numbers that have been written with a thousands separator, you can
992992
set the ``thousands`` keyword to a string of length 1 so that integers will be parsed
993-
correctly:
993+
correctly.
994994

995995
By default, numbers with a thousands separator will be parsed as strings:
996996

doc/source/user_guide/merging.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ A string argument to ``indicator`` will use the value as the name for the indica
586586
Overlapping value columns
587587
~~~~~~~~~~~~~~~~~~~~~~~~~
588588

589-
The merge ``suffixes`` argument takes a tuple of list of strings to append to
589+
The merge ``suffixes`` argument takes a tuple or list of strings to append to
590590
overlapping column names in the input :class:`DataFrame` to disambiguate the result
591591
columns:
592592

@@ -979,7 +979,7 @@ nearest key rather than equal keys. For each row in the ``left`` :class:`DataFra
979979
the last row in the ``right`` :class:`DataFrame` are selected where the ``on`` key is less
980980
than the left's key. Both :class:`DataFrame` must be sorted by the key.
981981

982-
Optionally an :func:`merge_asof` can perform a group-wise merge by matching the
982+
Optionally :func:`merge_asof` can perform a group-wise merge by matching the
983983
``by`` key in addition to the nearest match on the ``on`` key.
984984

985985
.. ipython:: python

doc/source/user_guide/scale.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Scaling to large datasets
55
*************************
66

77
pandas provides data structures for in-memory analytics, which makes using pandas
8-
to analyze datasets that are larger than memory datasets somewhat tricky. Even datasets
8+
to analyze datasets that are larger than memory somewhat tricky. Even datasets
99
that are a sizable fraction of memory become unwieldy, as some pandas operations need
1010
to make intermediate copies.
1111

doc/source/user_guide/timeseries.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,7 +1580,7 @@ the pandas objects.
15801580
ts = ts[:5]
15811581
ts.shift(1)
15821582
1583-
The ``shift`` method accepts an ``freq`` argument which can accept a
1583+
The ``shift`` method accepts a ``freq`` argument which can accept a
15841584
``DateOffset`` class or other ``timedelta``-like object or also an
15851585
:ref:`offset alias <timeseries.offset_aliases>`.
15861586

@@ -2570,7 +2570,7 @@ because daylight savings time (DST) in a local time zone causes some times to oc
25702570
twice within one day ("clocks fall back"). The following options are available:
25712571

25722572
* ``'raise'``: Raises a ``ValueError`` (the default behavior)
2573-
* ``'infer'``: Attempt to determine the correct offset base on the monotonicity of the timestamps
2573+
* ``'infer'``: Attempt to determine the correct offset based on the monotonicity of the timestamps
25742574
* ``'NaT'``: Replaces ambiguous times with ``NaT``
25752575
* ``bool``: ``True`` represents a DST time, ``False`` represents non-DST time. An array-like of ``bool`` values is supported for a sequence of times.
25762576

doc/source/whatsnew/v3.0.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,7 @@ Styler
793793
Other
794794
^^^^^
795795
- Bug in :class:`DataFrame` when passing a ``dict`` with a NA scalar and ``columns`` that would always return ``np.nan`` (:issue:`57205`)
796+
- Bug in :class:`Series` ignoring errors when trying to convert :class:`Series` input data to the given ``dtype`` (:issue:`60728`)
796797
- Bug in :func:`eval` on :class:`ExtensionArray` on including division ``/`` failed with a ``TypeError``. (:issue:`58748`)
797798
- Bug in :func:`eval` where the names of the :class:`Series` were not preserved when using ``engine="numexpr"``. (:issue:`10239`)
798799
- Bug in :func:`eval` with ``engine="numexpr"`` returning unexpected result for float division. (:issue:`59736`)

pandas/_config/config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,11 @@ def option_context(*args) -> Generator[None]:
433433
"""
434434
Context manager to temporarily set options in a ``with`` statement.
435435
436+
This method allows users to set one or more pandas options temporarily
437+
within a controlled block. The previous options' values are restored
438+
once the block is exited. This is useful when making temporary adjustments
439+
to pandas' behavior without affecting the global state.
440+
436441
Parameters
437442
----------
438443
*args : str | object

pandas/_libs/tslibs/period.pyx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2842,6 +2842,11 @@ class Period(_Period):
28422842
"""
28432843
Represents a period of time.
28442844
2845+
A `Period` represents a specific time span rather than a point in time.
2846+
Unlike `Timestamp`, which represents a single instant, a `Period` defines a
2847+
duration, such as a month, quarter, or year. The exact representation is
2848+
determined by the `freq` parameter.
2849+
28452850
Parameters
28462851
----------
28472852
value : Period, str, datetime, date or pandas.Timestamp, default None

pandas/core/construction.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ def array(
8181
"""
8282
Create an array.
8383
84+
This method constructs an array using pandas extension types when possible.
85+
If `dtype` is specified, it determines the type of array returned. Otherwise,
86+
pandas attempts to infer the appropriate dtype based on `data`.
87+
8488
Parameters
8589
----------
8690
data : Sequence of objects

pandas/core/frame.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,10 @@ def shape(self) -> tuple[int, int]:
10211021
"""
10221022
Return a tuple representing the dimensionality of the DataFrame.
10231023
1024+
Unlike the `len()` method, which only returns the number of rows, `shape`
1025+
provides both row and column counts, making it a more informative method for
1026+
understanding dataset size.
1027+
10241028
See Also
10251029
--------
10261030
numpy.ndarray.shape : Tuple of array dimensions.

pandas/core/groupby/groupby.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3659,10 +3659,10 @@ def rolling(
36593659
Parameters
36603660
----------
36613661
window : int, timedelta, str, offset, or BaseIndexer subclass
3662-
Size of the moving window.
3662+
Interval of the moving window.
36633663
3664-
If an integer, the fixed number of observations used for
3665-
each window.
3664+
If an integer, the delta between the start and end of each window.
3665+
The number of points in the window depends on the ``closed`` argument.
36663666
36673667
If a timedelta, str, or offset, the time period of each window. Each
36683668
window will be a variable sized based on the observations included in
@@ -3709,17 +3709,18 @@ def rolling(
37093709
37103710
closed : str, default None
37113711
Determines the inclusivity of points in the window
3712-
If ``'right'``, (First, Last] the last point in the window
3712+
3713+
If ``'right'``, uses the window (first, last] meaning the last point
37133714
is included in the calculations.
37143715
3715-
If ``'left'``, [First, Last) the first point in the window
3716+
If ``'left'``, uses the window [first, last) meaning the first point
37163717
is included in the calculations.
37173718
3718-
If ``'both'``, [First, Last] all points in the window
3719-
are included in the calculations.
3719+
If ``'both'``, uses the window [first, last] meaning all points in
3720+
the window are included in the calculations.
37203721
3721-
If ``'neither'``, (First, Last) the first and last points
3722-
in the window are excludedfrom calculations.
3722+
If ``'neither'``, uses the window (first, last) meaning the first
3723+
and last points in the window are excluded from calculations.
37233724
37243725
() and [] are referencing open and closed set
37253726
notation respetively.

pandas/core/series.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ def __init__(
500500
# create/copy the manager
501501
if isinstance(data, SingleBlockManager):
502502
if dtype is not None:
503-
data = data.astype(dtype=dtype, errors="ignore")
503+
data = data.astype(dtype=dtype)
504504
elif copy:
505505
data = data.copy()
506506
else:

pandas/core/window/rolling.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -881,10 +881,10 @@ class Window(BaseWindow):
881881
Parameters
882882
----------
883883
window : int, timedelta, str, offset, or BaseIndexer subclass
884-
Size of the moving window.
884+
Interval of the moving window.
885885
886-
If an integer, the fixed number of observations used for
887-
each window.
886+
If an integer, the delta between the start and end of each window.
887+
The number of points in the window depends on the ``closed`` argument.
888888
889889
If a timedelta, str, or offset, the time period of each window. Each
890890
window will be a variable sized based on the observations included in
@@ -930,17 +930,18 @@ class Window(BaseWindow):
930930
931931
closed : str, default None
932932
Determines the inclusivity of points in the window
933-
If ``'right'``, (First, Last] the last point in the window
933+
934+
If ``'right'``, uses the window (first, last] meaning the last point
934935
is included in the calculations.
935936
936-
If ``'left'``, [First, Last) the first point in the window
937+
If ``'left'``, uses the window [first, last) meaning the first point
937938
is included in the calculations.
938939
939-
If ``'both'``, [First, Last] all points in the window
940-
are included in the calculations.
940+
If ``'both'``, uses the window [first, last] meaning all points in
941+
the window are included in the calculations.
941942
942-
If ``'neither'``, (First, Last) the first and last points
943-
in the window are excludedfrom calculations.
943+
If ``'neither'``, uses the window (first, last) meaning the first
944+
and last points in the window are excluded from calculations.
944945
945946
() and [] are referencing open and closed set
946947
notation respetively.

pandas/tests/series/test_constructors.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@ def test_unparsable_strings_with_dt64_dtype(self):
9090
with pytest.raises(ValueError, match=msg):
9191
Series(np.array(vals, dtype=object), dtype="datetime64[ns]")
9292

93+
def test_invalid_dtype_conversion_datetime_to_timedelta(self):
94+
# GH#60728
95+
vals = Series([NaT, Timestamp(2025, 1, 1)], dtype="datetime64[ns]")
96+
msg = r"^Cannot cast DatetimeArray to dtype timedelta64\[ns\]$"
97+
with pytest.raises(TypeError, match=msg):
98+
Series(vals, dtype="timedelta64[ns]")
99+
93100
@pytest.mark.parametrize(
94101
"constructor",
95102
[

0 commit comments

Comments
 (0)