Skip to content

Commit a617e33

Browse files
committed
Merge remote-tracking branch 'upstream/main' into main
2 parents 6157e7b + 05d12b5 commit a617e33

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+944
-713
lines changed

doc/source/development/maintaining.rst

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,8 @@ which will be triggered when the tag is pushed.
458458
git checkout master
459459
git pull --ff-only upstream master
460460
git checkout -B RLS-<version>
461-
sed -i 's/BUILD_COMMIT: "v.*/BUILD_COMMIT: "'<version>'"/' azure/windows.yml azure/posix.yml
462-
sed -i 's/BUILD_COMMIT="v.*/BUILD_COMMIT="'<version>'"/' .travis.yml
461+
sed -i 's/BUILD_COMMIT: "v.*/BUILD_COMMIT: "'v<version>'"/' azure/windows.yml azure/posix.yml
462+
sed -i 's/BUILD_COMMIT="v.*/BUILD_COMMIT="'v<version>'"/' .travis.yml
463463
git commit -am "RLS <version>"
464464
git push -u origin RLS-<version>
465465

@@ -474,14 +474,21 @@ which will be triggered when the tag is pushed.
474474
Post-Release
475475
````````````
476476

477-
1. Close the milestone and the issue for the released version.
477+
1. Update symlink to stable documentation by logging in to our web server, and
478+
editing ``/var/www/html/pandas-docs/stable`` to point to ``version/<latest-version>``.
478479

479-
2. Create a new issue for the next release, with the estimated date or release.
480+
2. If releasing a major or minor release, open a PR in our source code to update
481+
``web/pandas/versions.json``, to have the desired versions in the documentation
482+
dropdown menu.
480483

481-
3. Open a PR with the placeholder for the release notes of the next version. See
484+
3. Close the milestone and the issue for the released version.
485+
486+
4. Create a new issue for the next release, with the estimated date of release.
487+
488+
5. Open a PR with the placeholder for the release notes of the next version. See
482489
for example [the PR for 1.5.3](https://github.com/pandas-dev/pandas/pull/49843/files).
483490

484-
4. Announce the new release in the official channels (use previous announcements
491+
6. Announce the new release in the official channels (use previous announcements
485492
for reference):
486493

487494
- The pandas-dev and pydata mailing lists

doc/source/whatsnew/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Version 1.5
2424
.. toctree::
2525
:maxdepth: 2
2626

27+
v1.5.4
2728
v1.5.3
2829
v1.5.2
2930
v1.5.1

doc/source/whatsnew/v1.5.2.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ Other
4343
Contributors
4444
~~~~~~~~~~~~
4545

46-
.. contributors:: v1.5.1..v1.5.2|HEAD
46+
.. contributors:: v1.5.1..v1.5.2

doc/source/whatsnew/v1.5.3.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,4 @@ Other
5555
Contributors
5656
~~~~~~~~~~~~
5757

58-
.. contributors:: v1.5.2..v1.5.3|HEAD
58+
.. contributors:: v1.5.2..v1.5.3

doc/source/whatsnew/v1.5.4.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
.. _whatsnew_154:
2+
3+
What's new in 1.5.4 (March XX, 2023)
4+
--------------------------------------
5+
6+
These are the changes in pandas 1.5.4. See :ref:`release` for a full changelog
7+
including other versions of pandas.
8+
9+
{{ header }}
10+
11+
.. ---------------------------------------------------------------------------
12+
.. _whatsnew_154.regressions:
13+
14+
Fixed regressions
15+
~~~~~~~~~~~~~~~~~
16+
-
17+
18+
.. ---------------------------------------------------------------------------
19+
.. _whatsnew_154.bug_fixes:
20+
21+
Bug fixes
22+
~~~~~~~~~
23+
-
24+
25+
.. ---------------------------------------------------------------------------
26+
.. _whatsnew_154.other:
27+
28+
Other
29+
~~~~~
30+
-
31+
32+
.. ---------------------------------------------------------------------------
33+
.. _whatsnew_154.contributors:
34+
35+
Contributors
36+
~~~~~~~~~~~~
37+
38+
.. contributors:: v1.5.3..v1.5.4|HEAD

doc/source/whatsnew/v2.0.0.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ Other enhancements
161161
- Added :meth:`Index.infer_objects` analogous to :meth:`Series.infer_objects` (:issue:`50034`)
162162
- Added ``copy`` parameter to :meth:`Series.infer_objects` and :meth:`DataFrame.infer_objects`, passing ``False`` will avoid making copies for series or columns that are already non-object or where no better dtype can be inferred (:issue:`50096`)
163163
- :meth:`DataFrame.plot.hist` now recognizes ``xlabel`` and ``ylabel`` arguments (:issue:`49793`)
164+
- :meth:`Series.drop_duplicates` has gained ``ignore_index`` keyword to reset index (:issue:`48304`)
164165
- Improved error message in :func:`to_datetime` for non-ISO8601 formats, informing users about the position of the first error (:issue:`50361`)
165166
- Improved error message when trying to align :class:`DataFrame` objects (for example, in :func:`DataFrame.compare`) to clarify that "identically labelled" refers to both index and columns (:issue:`50083`)
166167
- Added :meth:`DatetimeIndex.as_unit` and :meth:`TimedeltaIndex.as_unit` to convert to different resolutions; supported resolutions are "s", "ms", "us", and "ns" (:issue:`50616`)
@@ -453,6 +454,37 @@ Now, the axes return an empty :class:`RangeIndex`.
453454
pd.Series().index
454455
pd.DataFrame().axes
455456
457+
.. _whatsnew_200.api_breaking.to_latex:
458+
459+
DataFrame to LaTeX has a new render engine
460+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
461+
462+
The existing :meth:`DataFrame.to_latex` has been restructured to utilise the
463+
extended implementation previously available under :meth:`.Styler.to_latex`.
464+
The arguments signature is similar, albeit ``col_space`` has been removed since
465+
it is ignored by LaTeX engines. This render engine also requires ``jinja2`` as a
466+
dependency which needs to be installed, since rendering is based upon jinja2 templates.
467+
468+
The pandas options below are no longer used and will be removed in future releases.
469+
The alternative options giving similar functionality are indicated below:
470+
471+
- ``display.latex.escape``: replaced with ``styler.format.escape``,
472+
- ``display.latex.longtable``: replaced with ``styler.latex.environment``,
473+
- ``display.latex.multicolumn``, ``display.latex.multicolumn_format`` and
474+
``display.latex.multirow``: replaced with ``styler.sparse.rows``,
475+
``styler.sparse.columns``, ``styler.latex.multirow_align`` and
476+
``styler.latex.multicol_align``,
477+
- ``display.latex.repr``: replaced with ``styler.render.repr``,
478+
- ``display.max_rows`` and ``display.max_columns``: replace with
479+
``styler.render.max_rows``, ``styler.render.max_columns`` and
480+
``styler.render.max_elements``.
481+
482+
Note that the behaviour of ``_repr_latex_`` is also changed. Previously
483+
setting ``display.latex.repr`` would generate LaTeX only when using nbconvert for a
484+
JupyterNotebook, and not when the user is running the notebook. Now the
485+
``styler.render.repr`` option allows control of the specific output
486+
within JupyterNotebooks for operations (not just on nbconvert). See :issue:`39911`.
487+
456488
.. _whatsnew_200.api_breaking.deps:
457489

458490
Increased minimum versions for dependencies
@@ -618,6 +650,7 @@ Removal of prior version deprecations/changes
618650
- Removed deprecated :meth:`.Styler.set_na_rep` and :meth:`.Styler.set_precision` (:issue:`49397`)
619651
- Removed deprecated :meth:`.Styler.where` (:issue:`49397`)
620652
- Removed deprecated :meth:`.Styler.render` (:issue:`49397`)
653+
- Removed deprecated argument ``col_space`` in :meth:`DataFrame.to_latex` (:issue:`47970`)
621654
- Removed deprecated argument ``null_color`` in :meth:`.Styler.highlight_null` (:issue:`49397`)
622655
- Removed deprecated argument ``check_less_precise`` in :meth:`.testing.assert_frame_equal`, :meth:`.testing.assert_extension_array_equal`, :meth:`.testing.assert_series_equal`, :meth:`.testing.assert_index_equal` (:issue:`30562`)
623656
- Removed deprecated ``null_counts`` argument in :meth:`DataFrame.info`. Use ``show_counts`` instead (:issue:`37999`)
@@ -792,6 +825,7 @@ Removal of prior version deprecations/changes
792825
- Changed behavior of comparison of ``NaT`` with a ``datetime.date`` object; these now raise on inequality comparisons (:issue:`39196`)
793826
- Enforced deprecation of silently dropping columns that raised a ``TypeError`` in :class:`Series.transform` and :class:`DataFrame.transform` when used with a list or dictionary (:issue:`43740`)
794827
- Changed behavior of :meth:`DataFrame.apply` with list-like so that any partial failure will raise an error (:issue:`43740`)
828+
- Changed behaviour of :meth:`DataFrame.to_latex` to now use the Styler implementation via :meth:`.Styler.to_latex` (:issue:`47970`)
795829
- Changed behavior of :meth:`Series.__setitem__` with an integer key and a :class:`Float64Index` when the key is not present in the index; previously we treated the key as positional (behaving like ``series.iloc[key] = val``), now we treat it is a label (behaving like ``series.loc[key] = val``), consistent with :meth:`Series.__getitem__`` behavior (:issue:`33469`)
796830
- Removed ``na_sentinel`` argument from :func:`factorize`, :meth:`.Index.factorize`, and :meth:`.ExtensionArray.factorize` (:issue:`47157`)
797831
- Changed behavior of :meth:`Series.diff` and :meth:`DataFrame.diff` with :class:`ExtensionDtype` dtypes whose arrays do not implement ``diff``, these now raise ``TypeError`` rather than casting to numpy (:issue:`31025`)
@@ -871,6 +905,7 @@ Performance improvements
871905
- Performance improvement in :class:`Period` constructor when constructing from a string or integer (:issue:`38312`)
872906
- Performance improvement in :func:`to_datetime` when using ``'%Y%m%d'`` format (:issue:`17410`)
873907
- Performance improvement in :func:`to_datetime` when format is given or can be inferred (:issue:`50465`)
908+
- Performance improvement in :meth:`Series.median` for nullable dtypes (:issue:`50838`)
874909
- Performance improvement in :func:`read_csv` when passing :func:`to_datetime` lambda-function to ``date_parser`` and inputs have mixed timezone offsetes (:issue:`35296`)
875910
- Performance improvement in :func:`isna` and :func:`isnull` (:issue:`50658`)
876911
- Performance improvement in :meth:`.SeriesGroupBy.value_counts` with categorical dtype (:issue:`46202`)
@@ -1023,6 +1058,7 @@ I/O
10231058
- Bug in :meth:`DataFrame.to_string` ignoring float formatter for extension arrays (:issue:`39336`)
10241059
- Fixed memory leak which stemmed from the initialization of the internal JSON module (:issue:`49222`)
10251060
- Fixed issue where :func:`json_normalize` would incorrectly remove leading characters from column names that matched the ``sep`` argument (:issue:`49861`)
1061+
- Bug in :func:`read_csv` unnecessarily overflowing for extension array dtype when containing ``NA`` (:issue:`32134`)
10261062
- Bug in :meth:`DataFrame.to_dict` not converting ``NA`` to ``None`` (:issue:`50795`)
10271063
- Bug in :meth:`DataFrame.to_json` where it would segfault when failing to encode a string (:issue:`50307`)
10281064
- Bug in :func:`read_xml` where file-like objects failed when iterparse is used (:issue:`50641`)

pandas/_libs/tslib.pyx

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,19 @@ def format_array_from_datetime(
220220
return result
221221

222222

223+
cdef int64_t _wrapped_cast_from_unit(object val, str unit) except? -1:
224+
"""
225+
Call cast_from_unit and re-raise OverflowError as OutOfBoundsDatetime
226+
"""
227+
# See also timedeltas._maybe_cast_from_unit
228+
try:
229+
return cast_from_unit(val, unit)
230+
except OverflowError as err:
231+
raise OutOfBoundsDatetime(
232+
f"cannot convert input {val} with the unit '{unit}'"
233+
) from err
234+
235+
223236
def array_with_unit_to_datetime(
224237
ndarray[object] values,
225238
str unit,
@@ -261,13 +274,10 @@ def array_with_unit_to_datetime(
261274
bint is_raise = errors=="raise"
262275
ndarray[int64_t] iresult
263276
object tz = None
264-
bint is_ym
265277
float fval
266278

267279
assert is_ignore or is_coerce or is_raise
268280

269-
is_ym = unit in "YM"
270-
271281
if unit == "ns":
272282
result, tz = array_to_datetime(
273283
values.astype(object, copy=False),
@@ -292,19 +302,7 @@ def array_with_unit_to_datetime(
292302
if val != val or val == NPY_NAT:
293303
iresult[i] = NPY_NAT
294304
else:
295-
if is_ym and is_float_object(val) and not val.is_integer():
296-
# Analogous to GH#47266 for Timestamp
297-
raise ValueError(
298-
f"Conversion of non-round float with unit={unit} "
299-
"is ambiguous"
300-
)
301-
302-
try:
303-
iresult[i] = cast_from_unit(val, unit)
304-
except OverflowError:
305-
raise OutOfBoundsDatetime(
306-
f"cannot convert input {val} with the unit '{unit}'"
307-
)
305+
iresult[i] = _wrapped_cast_from_unit(val, unit)
308306

309307
elif isinstance(val, str):
310308
if len(val) == 0 or val in nat_strings:
@@ -319,23 +317,7 @@ def array_with_unit_to_datetime(
319317
f"non convertible value {val} with the unit '{unit}'"
320318
)
321319

322-
if is_ym and not fval.is_integer():
323-
# Analogous to GH#47266 for Timestamp
324-
raise ValueError(
325-
f"Conversion of non-round float with unit={unit} "
326-
"is ambiguous"
327-
)
328-
329-
try:
330-
iresult[i] = cast_from_unit(fval, unit)
331-
except ValueError:
332-
raise ValueError(
333-
f"non convertible value {val} with the unit '{unit}'"
334-
)
335-
except OverflowError:
336-
raise OutOfBoundsDatetime(
337-
f"cannot convert input {val} with the unit '{unit}'"
338-
)
320+
iresult[i] = _wrapped_cast_from_unit(fval, unit)
339321

340322
else:
341323
# TODO: makes more sense as TypeError, but that would be an

pandas/_libs/tslibs/conversion.pyx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,15 @@ cdef int64_t cast_from_unit(object ts, str unit) except? -1:
108108
if ts is None:
109109
return m
110110

111+
if unit in ["Y", "M"] and is_float_object(ts) and not ts.is_integer():
112+
# GH#47267 it is clear that 2 "M" corresponds to 1970-02-01,
113+
# but not clear what 2.5 "M" corresponds to, so we will
114+
# disallow that case.
115+
raise ValueError(
116+
f"Conversion of non-round float with unit={unit} "
117+
"is ambiguous"
118+
)
119+
111120
# cast the unit, multiply base/frace separately
112121
# to avoid precision issues from float -> int
113122
base = <int64_t>ts
@@ -287,13 +296,6 @@ cdef _TSObject convert_to_tsobject(object ts, tzinfo tz, str unit,
287296
# GH#47266 Avoid cast_from_unit, which would give weird results
288297
# e.g. with "Y" and 150.0 we'd get 2120-01-01 09:00:00
289298
return convert_to_tsobject(int(ts), tz, unit, False, False)
290-
else:
291-
# GH#47267 it is clear that 2 "M" corresponds to 1970-02-01,
292-
# but not clear what 2.5 "M" corresponds to, so we will
293-
# disallow that case.
294-
raise ValueError(
295-
f"Conversion of non-round float with unit={unit} is ambiguous."
296-
)
297299

298300
ts = cast_from_unit(ts, unit)
299301
obj.value = ts

pandas/core/arrays/masked.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,12 +1081,7 @@ def _reduce(self, name: str, *, skipna: bool = True, **kwargs):
10811081
data = self._data
10821082
mask = self._mask
10831083

1084-
# coerce to a nan-aware float if needed
1085-
# (we explicitly use NaN within reductions)
1086-
if self._hasna:
1087-
data = self.to_numpy("float64", na_value=np.nan)
1088-
1089-
# median, skew, kurt, idxmin, idxmax
1084+
# median, skew, kurt, sem
10901085
op = getattr(nanops, f"nan{name}")
10911086
result = op(data, axis=0, skipna=skipna, mask=mask, **kwargs)
10921087

pandas/core/arrays/numeric.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ def _from_sequence_of_strings(
285285
) -> T:
286286
from pandas.core.tools.numeric import to_numeric
287287

288-
scalars = to_numeric(strings, errors="raise")
288+
scalars = to_numeric(strings, errors="raise", use_nullable_dtypes=True)
289289
return cls._from_sequence(scalars, dtype=dtype, copy=copy)
290290

291291
_HANDLED_TYPES = (np.ndarray, numbers.Number)

0 commit comments

Comments
 (0)