Skip to content

Commit ca480bf

Browse files
Merge remote-tracking branch 'upstream/main' into bisect
2 parents 9c44c81 + 72d8ec2 commit ca480bf

Some content is hidden

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

46 files changed

+673
-366
lines changed

doc/source/getting_started/install.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Instructions for installing from source,
2020
Python version support
2121
----------------------
2222

23-
Officially Python 3.8, and 3.9.
23+
Officially Python 3.8, 3.9 and 3.10.
2424

2525
Installing pandas
2626
-----------------

doc/source/user_guide/style.ipynb

+4-1
Original file line numberDiff line numberDiff line change
@@ -1577,6 +1577,9 @@
15771577
"Some support (*since version 0.20.0*) is available for exporting styled `DataFrames` to Excel worksheets using the `OpenPyXL` or `XlsxWriter` engines. CSS2.2 properties handled include:\n",
15781578
"\n",
15791579
"- `background-color`\n",
1580+
"- `border-style` properties\n",
1581+
"- `border-width` properties\n",
1582+
"- `border-color` properties\n",
15801583
"- `color`\n",
15811584
"- `font-family`\n",
15821585
"- `font-style`\n",
@@ -1587,7 +1590,7 @@
15871590
"- `white-space: nowrap`\n",
15881591
"\n",
15891592
"\n",
1590-
"- Currently broken: `border-style`, `border-width`, `border-color` and their {`top`, `right`, `bottom`, `left` variants}\n",
1593+
"- Shorthand and side-specific border properties are supported (e.g. `border-style` and `border-left-style`) as well as the `border` shorthands for all sides (`border: 1px solid green`) or specified sides (`border-left: 1px solid green`). Using a `border` shorthand will override any border properties set before it (See [CSS Working Group](https://drafts.csswg.org/css-backgrounds/#border-shorthands) for more details)\n",
15911594
"\n",
15921595
"\n",
15931596
"- Only CSS2 named colors and hex colors of the form `#rgb` or `#rrggbb` are currently supported.\n",

doc/source/whatsnew/v1.4.1.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.. _whatsnew_141:
22

3-
What's new in 1.4.1 (February ??, 2022)
3+
What's new in 1.4.1 (February 12, 2022)
44
---------------------------------------
55

66
These are the changes in pandas 1.4.1. See :ref:`release` for a full changelog
@@ -16,15 +16,15 @@ Fixed regressions
1616
~~~~~~~~~~~~~~~~~
1717
- Regression in :meth:`Series.mask` with ``inplace=True`` and ``PeriodDtype`` and an incompatible ``other`` coercing to a common dtype instead of raising (:issue:`45546`)
1818
- Regression in :func:`.assert_frame_equal` not respecting ``check_flags=False`` (:issue:`45554`)
19-
- Regression in :meth:`DataFrame.loc.__getitem__` raising ``ValueError`` when indexing on a :class:`MultiIndex` with one level (:issue:`45779`)
19+
- Regression in :meth:`DataFrame.loc` raising ``ValueError`` when indexing (getting values) on a :class:`MultiIndex` with one level (:issue:`45779`)
2020
- Regression in :meth:`Series.fillna` with ``downcast=False`` incorrectly downcasting ``object`` dtype (:issue:`45603`)
2121
- Regression in :func:`api.types.is_bool_dtype` raising an ``AttributeError`` when evaluating a categorical :class:`Series` (:issue:`45615`)
2222
- Regression in :meth:`DataFrame.iat` setting values leading to not propagating correctly in subsequent lookups (:issue:`45684`)
2323
- Regression when setting values with :meth:`DataFrame.loc` losing :class:`Index` name if :class:`DataFrame` was empty before (:issue:`45621`)
2424
- Regression in :meth:`~Index.join` with overlapping :class:`IntervalIndex` raising an ``InvalidIndexError`` (:issue:`45661`)
25-
- Regression in :meth:`Series.loc.__setitem__` raising with all ``False`` indexer and :class:`Series` on the right hand side (:issue:`45778`)
25+
- Regression when setting values with :meth:`Series.loc` raising with all ``False`` indexer and :class:`Series` on the right hand side (:issue:`45778`)
2626
- Regression in :func:`read_sql` with a DBAPI2 connection that is not an instance of ``sqlite3.Connection`` incorrectly requiring SQLAlchemy be installed (:issue:`45660`)
27-
-
27+
- Regression in :class:`DateOffset` when constructing with an integer argument with no keywords (e.g. ``pd.DateOffset(n)``) would behave like ``datetime.timedelta(days=0)`` (:issue:`45643`, :issue:`45890`)
2828

2929
.. ---------------------------------------------------------------------------
3030
@@ -36,6 +36,7 @@ Bug fixes
3636
- Stopped emitting unnecessary ``FutureWarning`` in :meth:`DataFrame.sort_values` with sparse columns (:issue:`45618`)
3737
- Fixed window aggregations in :meth:`DataFrame.rolling` and :meth:`Series.rolling` to skip over unused elements (:issue:`45647`)
3838
- Fixed builtin highlighters in :class:`.Styler` to be responsive to ``NA`` with nullable dtypes (:issue:`45804`)
39+
- Bug in :meth:`~Rolling.apply` with ``axis=1`` raising an erroneous ``ValueError`` (:issue:`45912`)
3940

4041
.. ---------------------------------------------------------------------------
4142
@@ -44,7 +45,6 @@ Bug fixes
4445
Other
4546
~~~~~
4647
- Reverted performance speedup of :meth:`DataFrame.corr` for ``method=pearson`` to fix precision regression (:issue:`45640`, :issue:`42761`)
47-
-
4848

4949
.. ---------------------------------------------------------------------------
5050

doc/source/whatsnew/v1.5.0.rst

+7-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Styler
2020
^^^^^^
2121

2222
- New method :meth:`.Styler.to_string` for alternative customisable output methods (:issue:`44502`)
23-
- Various bug fixes, see below.
23+
- Added the ability to render ``border`` and ``border-{side}`` CSS properties in Excel (:issue:`42276`)
2424

2525
.. _whatsnew_150.enhancements.enhancement2:
2626

@@ -38,6 +38,8 @@ Other enhancements
3838
- :meth:`Series.reset_index` and :meth:`DataFrame.reset_index` now support the argument ``allow_duplicates`` (:issue:`44410`)
3939
- :meth:`.GroupBy.min` and :meth:`.GroupBy.max` now supports `Numba <https://numba.pydata.org/>`_ execution with the ``engine`` keyword (:issue:`45428`)
4040
- Implemented a ``bool``-dtype :class:`Index`, passing a bool-dtype arraylike to ``pd.Index`` will now retain ``bool`` dtype instead of casting to ``object`` (:issue:`45061`)
41+
- Implemented a complex-dtype :class:`Index`, passing a complex-dtype arraylike to ``pd.Index`` will now retain complex dtype instead of casting to ``object`` (:issue:`45845`)
42+
4143
-
4244

4345
.. ---------------------------------------------------------------------------
@@ -50,8 +52,10 @@ These are bug fixes that might have notable behavior changes.
5052

5153
.. _whatsnew_150.notable_bug_fixes.notable_bug_fix1:
5254

53-
notable_bug_fix1
54-
^^^^^^^^^^^^^^^^
55+
Styler
56+
^^^^^^
57+
58+
- Fixed bug in :class:`CSSToExcelConverter` leading to ``TypeError`` when border color provided without border style for ``xlsxwriter`` engine (:issue:`42276`)
5559

5660
.. _whatsnew_150.notable_bug_fixes.notable_bug_fix2:
5761

environment.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ dependencies:
3232
# documentation
3333
- gitpython # obtain contributors from git for whatsnew
3434
- gitdb
35-
- numpydoc < 1.2 # 2021-02-09 1.2dev breaking CI
35+
- numpydoc
3636
- pandas-dev-flaker=0.4.0
3737
- pydata-sphinx-theme
3838
- pytest-cython

pandas/_libs/index.pyi

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class IndexEngine:
3030

3131
class Float64Engine(IndexEngine): ...
3232
class Float32Engine(IndexEngine): ...
33+
class Complex128Engine(IndexEngine): ...
34+
class Complex64Engine(IndexEngine): ...
3335
class Int64Engine(IndexEngine): ...
3436
class Int32Engine(IndexEngine): ...
3537
class Int16Engine(IndexEngine): ...

pandas/_libs/index_class_helper.pxi.in

+11-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ dtypes = [('Float64', 'float64'),
2121
('UInt32', 'uint32'),
2222
('UInt16', 'uint16'),
2323
('UInt8', 'uint8'),
24+
('Complex64', 'complex64'),
25+
('Complex128', 'complex128'),
2426
]
2527
}}
2628

@@ -33,7 +35,7 @@ cdef class {{name}}Engine(IndexEngine):
3335
return _hash.{{name}}HashTable(n)
3436

3537
cdef _check_type(self, object val):
36-
{{if name not in {'Float64', 'Float32'} }}
38+
{{if name not in {'Float64', 'Float32', 'Complex64', 'Complex128'} }}
3739
if not util.is_integer_object(val):
3840
if util.is_float_object(val):
3941
# Make sure Int64Index.get_loc(2.0) works
@@ -45,10 +47,17 @@ cdef class {{name}}Engine(IndexEngine):
4547
# cannot have negative values with unsigned int dtype
4648
raise KeyError(val)
4749
{{endif}}
48-
{{else}}
50+
{{elif name not in {'Complex64', 'Complex128'} }}
4951
if not util.is_integer_object(val) and not util.is_float_object(val):
5052
# in particular catch bool and avoid casting True -> 1.0
5153
raise KeyError(val)
54+
{{else}}
55+
if (not util.is_integer_object(val)
56+
and not util.is_float_object(val)
57+
and not util.is_complex_object(val)
58+
):
59+
# in particular catch bool and avoid casting True -> 1.0
60+
raise KeyError(val)
5261
{{endif}}
5362
return val
5463

pandas/_libs/tslibs/offsets.pyx

+6-1
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,12 @@ cdef _determine_offset(kwds):
333333
else:
334334
# sub-daily offset - use timedelta (tz-aware)
335335
offset = timedelta(**kwds_no_nanos)
336+
elif any(nano in kwds for nano in ('nanosecond', 'nanoseconds')):
337+
offset = timedelta(days=0)
336338
else:
337-
offset = timedelta(0)
339+
# GH 45643/45890: (historically) defaults to 1 day for non-nano
340+
# since datetime.timedelta doesn't handle nanoseconds
341+
offset = timedelta(days=1)
338342
return offset, use_relativedelta
339343

340344

@@ -1223,6 +1227,7 @@ class DateOffset(RelativeDeltaOffset, metaclass=OffsetMeta):
12231227
----------
12241228
n : int, default 1
12251229
The number of time periods the offset represents.
1230+
If specified without a temporal pattern, defaults to n days.
12261231
normalize : bool, default False
12271232
Whether to round the result of a DateOffset addition down to the
12281233
previous midnight.

pandas/conftest.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,9 @@ def pytest_collection_modifyitems(items, config):
155155
# is too short for a specific test, (a) try to make it faster, and (b)
156156
# if it really is slow add `@settings(deadline=...)` with a working value,
157157
# or `deadline=None` to entirely disable timeouts for that test.
158-
deadline=500,
158+
# 2022-02-09: Changed deadline from 500 -> None. Deadline leads to
159+
# non-actionable, flaky CI failures (# GH 24641, 44969, 45118, 44969)
160+
deadline=None,
159161
suppress_health_check=(hypothesis.HealthCheck.too_slow,),
160162
)
161163
hypothesis.settings.load_profile("ci")
@@ -545,6 +547,8 @@ def _create_mi_with_dt64tz_level():
545547
"uint": tm.makeUIntIndex(100),
546548
"range": tm.makeRangeIndex(100),
547549
"float": tm.makeFloatIndex(100),
550+
"complex64": tm.makeFloatIndex(100).astype("complex64"),
551+
"complex128": tm.makeFloatIndex(100).astype("complex128"),
548552
"num_int64": tm.makeNumericIndex(100, dtype="int64"),
549553
"num_int32": tm.makeNumericIndex(100, dtype="int32"),
550554
"num_int16": tm.makeNumericIndex(100, dtype="int16"),

pandas/core/common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ def pipe(
475475
func : callable or tuple of (callable, str)
476476
Function to apply to this object or, alternatively, a
477477
``(callable, data_keyword)`` tuple where ``data_keyword`` is a
478-
string indicating the keyword of `callable`` that expects the
478+
string indicating the keyword of ``callable`` that expects the
479479
object.
480480
*args : iterable, optional
481481
Positional arguments passed into ``func``.

pandas/core/generic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11443,7 +11443,7 @@ def _find_valid_index(self, *, how: str) -> Hashable | None:
1144311443
@doc(position="first", klass=_shared_doc_kwargs["klass"])
1144411444
def first_valid_index(self) -> Hashable | None:
1144511445
"""
11446-
Return index for {position} non-NA value or None, if no NA value is found.
11446+
Return index for {position} non-NA value or None, if no non-NA value is found.
1144711447
1144811448
Returns
1144911449
-------

pandas/core/indexes/base.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ def __new__(
505505
if data.dtype.kind in ["i", "u", "f"]:
506506
# maybe coerce to a sub-class
507507
arr = data
508-
elif data.dtype.kind == "b":
508+
elif data.dtype.kind in ["b", "c"]:
509509
# No special subclass, and Index._ensure_array won't do this
510510
# for us.
511511
arr = np.asarray(data)
@@ -636,7 +636,9 @@ def _dtype_to_subclass(cls, dtype: DtypeObj):
636636
# NB: assuming away MultiIndex
637637
return Index
638638

639-
elif issubclass(dtype.type, (str, bool, np.bool_)):
639+
elif issubclass(
640+
dtype.type, (str, bool, np.bool_, complex, np.complex64, np.complex128)
641+
):
640642
return Index
641643

642644
raise NotImplementedError(dtype)
@@ -881,6 +883,10 @@ def _engine(
881883
# `self` is not passed into the lambda.
882884
if target_values.dtype == bool:
883885
return libindex.BoolEngine(target_values)
886+
elif target_values.dtype == np.complex64:
887+
return libindex.Complex64Engine(target_values)
888+
elif target_values.dtype == np.complex128:
889+
return libindex.Complex128Engine(target_values)
884890

885891
# error: Argument 1 to "ExtensionEngine" has incompatible type
886892
# "ndarray[Any, Any]"; expected "ExtensionArray"
@@ -6162,9 +6168,6 @@ def _find_common_type_compat(self, target) -> DtypeObj:
61626168

61636169
dtype = find_common_type([self.dtype, target_dtype])
61646170
dtype = common_dtype_categorical_compat([self, target], dtype)
6165-
6166-
if dtype.kind == "c":
6167-
dtype = _dtype_obj
61686171
return dtype
61696172

61706173
@final
@@ -7308,8 +7311,6 @@ def _maybe_cast_data_without_dtype(
73087311
FutureWarning,
73097312
stacklevel=3,
73107313
)
7311-
if result.dtype.kind in ["c"]:
7312-
return subarr
73137314
result = ensure_wrapped_if_datetimelike(result)
73147315
return result
73157316

pandas/core/indexes/numeric.py

+3
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ class NumericIndex(Index):
101101
np.dtype(np.uint64): libindex.UInt64Engine,
102102
np.dtype(np.float32): libindex.Float32Engine,
103103
np.dtype(np.float64): libindex.Float64Engine,
104+
np.dtype(np.complex64): libindex.Complex64Engine,
105+
np.dtype(np.complex128): libindex.Complex128Engine,
104106
}
105107

106108
@property
@@ -115,6 +117,7 @@ def inferred_type(self) -> str:
115117
"i": "integer",
116118
"u": "integer",
117119
"f": "floating",
120+
"c": "complex",
118121
}[self.dtype.kind]
119122

120123
def __new__(cls, data=None, dtype: Dtype | None = None, copy=False, name=None):

0 commit comments

Comments
 (0)