Skip to content

Commit e930b2b

Browse files
committed
Merge remote-tracking branch 'upstream/master' into 28547
2 parents c1327c0 + 35029d2 commit e930b2b

File tree

20 files changed

+245
-282
lines changed

20 files changed

+245
-282
lines changed

doc/source/whatsnew/v1.0.0.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more.
376376

377377
**Other removals**
378378

379+
- Removed the previously deprecated :meth:`Index.summary` (:issue:`18217`)
379380
- Removed the previously deprecated :meth:`Series.get_value`, :meth:`Series.set_value`, :meth:`DataFrame.get_value`, :meth:`DataFrame.set_value` (:issue:`17739`)
380381
- Changed the the default value of `inplace` in :meth:`DataFrame.set_index` and :meth:`Series.set_axis`. It now defaults to False (:issue:`27600`)
381382
- Removed support for nested renaming in :meth:`DataFrame.aggregate`, :meth:`Series.aggregate`, :meth:`DataFrameGroupBy.aggregate`, :meth:`SeriesGroupBy.aggregate`, :meth:`Rolling.aggregate` (:issue:`18529`)
@@ -391,6 +392,7 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more.
391392
- Removed the previously deprecated :meth:`ExtensionArray._formatting_values`. Use :attr:`ExtensionArray._formatter` instead. (:issue:`23601`)
392393
- Removed support for legacy HDF5 formats (:issue:`29787`)
393394
- :func:`read_excel` removed support for "skip_footer" argument, use "skipfooter" instead (:issue:`18836`)
395+
- :func:`read_excel` no longer allows an integer value for the parameter ``usecols``, instead pass a list of integers from 0 to ``usecols`` inclusive (:issue:`23635`)
394396
- :meth:`DataFrame.to_records` no longer supports the argument "convert_datetime64" (:issue:`18902`)
395397
- Removed the previously deprecated ``IntervalIndex.from_intervals`` in favor of the :class:`IntervalIndex` constructor (:issue:`19263`)
396398
- Changed the default value for the "keep_tz" argument in :meth:`DatetimeIndex.to_series` to ``True`` (:issue:`23739`)
@@ -595,6 +597,7 @@ Reshaping
595597

596598
- Bug in :meth:`DataFrame.apply` that caused incorrect output with empty :class:`DataFrame` (:issue:`28202`, :issue:`21959`)
597599
- Bug in :meth:`DataFrame.stack` not handling non-unique indexes correctly when creating MultiIndex (:issue: `28301`)
600+
- Bug in :meth:`pivot_table` not returning correct type ``float`` when ``margins=True`` and ``aggfunc='mean'`` (:issue:`24893`)
598601
- Bug :func:`merge_asof` could not use :class:`datetime.timedelta` for ``tolerance`` kwarg (:issue:`28098`)
599602
- Bug in :func:`merge`, did not append suffixes correctly with MultiIndex (:issue:`28518`)
600603
- :func:`qcut` and :func:`cut` now handle boolean input (:issue:`20303`)
@@ -603,6 +606,8 @@ Reshaping
603606
- Bug :meth:`Series.pct_change` where supplying an anchored frequency would throw a ValueError (:issue:`28664`)
604607
- Bug where :meth:`DataFrame.equals` returned True incorrectly in some cases when two DataFrames had the same columns in different orders (:issue:`28839`)
605608
- Bug in :meth:`DataFrame.replace` that caused non-numeric replacer's dtype not respected (:issue:`26632`)
609+
- Bug in :func:`melt` where supplying mixed strings and numeric values for ``id_vars`` or ``value_vars`` would incorrectly raise a ``ValueError`` (:issue:`29718`)
610+
606611

607612
Sparse
608613
^^^^^^

pandas/_libs/tslibs/strptime.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def array_strptime(object[:] values, object fmt,
110110
f"in format '{fmt}'")
111111
# IndexError only occurs when the format string is "%"
112112
except IndexError:
113-
raise ValueError("stray % in format '{fmt}'")
113+
raise ValueError(f"stray % in format '{fmt}'")
114114
_regex_cache[fmt] = format_regex
115115

116116
result = np.empty(n, dtype='M8[ns]')

pandas/_libs/window/__init__.py

Whitespace-only changes.
File renamed without changes.

pandas/_libs/window_indexer.pyx renamed to pandas/_libs/window/indexers.pyx

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# cython: boundscheck=False, wraparound=False, cdivision=True
22

3+
from typing import Tuple
4+
35
import numpy as np
46
from numpy cimport ndarray, int64_t
57

@@ -8,33 +10,6 @@ from numpy cimport ndarray, int64_t
810
# These define start/end indexers to compute offsets
911

1012

11-
class MockFixedWindowIndexer:
12-
"""
13-
14-
We are just checking parameters of the indexer,
15-
and returning a consistent API with fixed/variable
16-
indexers.
17-
18-
Parameters
19-
----------
20-
values: ndarray
21-
values data array
22-
win: int64_t
23-
window size
24-
index: object
25-
index of the values
26-
closed: string
27-
closed behavior
28-
"""
29-
def __init__(self, ndarray values, int64_t win, object closed, object index=None):
30-
31-
self.start = np.empty(0, dtype='int64')
32-
self.end = np.empty(0, dtype='int64')
33-
34-
def get_window_bounds(self):
35-
return self.start, self.end
36-
37-
3813
class FixedWindowIndexer:
3914
"""
4015
create a fixed length window indexer object
@@ -66,7 +41,7 @@ class FixedWindowIndexer:
6641
end_e = start_e + win
6742
self.end = np.concatenate([end_s, end_e])[:N]
6843

69-
def get_window_bounds(self):
44+
def get_window_bounds(self) -> Tuple[np.ndarray, np.ndarray]:
7045
return self.start, self.end
7146

7247

@@ -108,7 +83,7 @@ class VariableWindowIndexer:
10883

10984
@staticmethod
11085
def build(const int64_t[:] index, int64_t win, bint left_closed,
111-
bint right_closed, int64_t N):
86+
bint right_closed, int64_t N) -> Tuple[np.ndarray, np.ndarray]:
11287

11388
cdef:
11489
ndarray[int64_t] start, end
@@ -161,5 +136,5 @@ class VariableWindowIndexer:
161136
end[i] -= 1
162137
return start, end
163138

164-
def get_window_bounds(self):
139+
def get_window_bounds(self) -> Tuple[np.ndarray, np.ndarray]:
165140
return self.start, self.end

pandas/core/indexes/base.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,19 +1132,6 @@ def _summary(self, name=None):
11321132
name = type(self).__name__
11331133
return f"{name}: {len(self)} entries{index_summary}"
11341134

1135-
def summary(self, name=None):
1136-
"""
1137-
Return a summarized representation.
1138-
1139-
.. deprecated:: 0.23.0
1140-
"""
1141-
warnings.warn(
1142-
"'summary' is deprecated and will be removed in a future version.",
1143-
FutureWarning,
1144-
stacklevel=2,
1145-
)
1146-
return self._summary(name)
1147-
11481135
# --------------------------------------------------------------------
11491136
# Conversion Methods
11501137

pandas/core/reshape/melt.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from pandas.core.dtypes.missing import notna
1212

1313
from pandas.core.arrays import Categorical
14+
import pandas.core.common as com
1415
from pandas.core.frame import DataFrame, _shared_docs
1516
from pandas.core.indexes.base import Index
1617
from pandas.core.reshape.concat import concat
@@ -47,7 +48,7 @@ def melt(
4748
else:
4849
# Check that `id_vars` are in frame
4950
id_vars = list(id_vars)
50-
missing = Index(np.ravel(id_vars)).difference(cols)
51+
missing = Index(com.flatten(id_vars)).difference(cols)
5152
if not missing.empty:
5253
raise KeyError(
5354
"The following 'id_vars' are not present"
@@ -69,7 +70,7 @@ def melt(
6970
else:
7071
value_vars = list(value_vars)
7172
# Check that `value_vars` are in frame
72-
missing = Index(np.ravel(value_vars)).difference(cols)
73+
missing = Index(com.flatten(value_vars)).difference(cols)
7374
if not missing.empty:
7475
raise KeyError(
7576
"The following 'value_vars' are not present in"

pandas/core/reshape/pivot.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,12 @@ def _add_margins(
261261

262262
row_names = result.index.names
263263
try:
264+
# check the result column and leave floats
264265
for dtype in set(result.dtypes):
265266
cols = result.select_dtypes([dtype]).columns
266-
margin_dummy[cols] = margin_dummy[cols].astype(dtype)
267+
margin_dummy[cols] = margin_dummy[cols].apply(
268+
maybe_downcast_to_dtype, args=(dtype,)
269+
)
267270
result = result.append(margin_dummy)
268271
except TypeError:
269272

pandas/core/window/ewm.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import numpy as np
44

5-
import pandas._libs.window as libwindow
5+
import pandas._libs.window.aggregations as window_aggregations
66
from pandas.compat.numpy import function as nv
77
from pandas.util._decorators import Appender, Substitution
88

@@ -228,11 +228,11 @@ def _apply(self, func, **kwargs):
228228

229229
# if we have a string function name, wrap it
230230
if isinstance(func, str):
231-
cfunc = getattr(libwindow, func, None)
231+
cfunc = getattr(window_aggregations, func, None)
232232
if cfunc is None:
233233
raise ValueError(
234234
"we do not support this function "
235-
"in libwindow.{func}".format(func=func)
235+
"in window_aggregations.{func}".format(func=func)
236236
)
237237

238238
def func(arg):
@@ -284,7 +284,7 @@ def var(self, bias=False, *args, **kwargs):
284284
nv.validate_window_func("var", args, kwargs)
285285

286286
def f(arg):
287-
return libwindow.ewmcov(
287+
return window_aggregations.ewmcov(
288288
arg,
289289
arg,
290290
self.com,
@@ -328,7 +328,7 @@ def cov(self, other=None, pairwise=None, bias=False, **kwargs):
328328
def _get_cov(X, Y):
329329
X = self._shallow_copy(X)
330330
Y = self._shallow_copy(Y)
331-
cov = libwindow.ewmcov(
331+
cov = window_aggregations.ewmcov(
332332
X._prep_values(),
333333
Y._prep_values(),
334334
self.com,
@@ -375,7 +375,7 @@ def _get_corr(X, Y):
375375
Y = self._shallow_copy(Y)
376376

377377
def _cov(x, y):
378-
return libwindow.ewmcov(
378+
return window_aggregations.ewmcov(
379379
x,
380380
y,
381381
self.com,

pandas/core/window/rolling.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
import numpy as np
1212

13-
import pandas._libs.window as libwindow
14-
import pandas._libs.window_indexer as libwindow_indexer
13+
import pandas._libs.window.aggregations as window_aggregations
14+
import pandas._libs.window.indexers as window_indexers
1515
from pandas.compat._optional import import_optional_dependency
1616
from pandas.compat.numpy import function as nv
1717
from pandas.util._decorators import Appender, Substitution, cache_readonly
@@ -381,11 +381,11 @@ def _get_roll_func(self, func_name: str) -> Callable:
381381
-------
382382
func : callable
383383
"""
384-
window_func = getattr(libwindow, func_name, None)
384+
window_func = getattr(window_aggregations, func_name, None)
385385
if window_func is None:
386386
raise ValueError(
387387
"we do not support this function "
388-
"in libwindow.{func_name}".format(func_name=func_name)
388+
"in window_aggregations.{func_name}".format(func_name=func_name)
389389
)
390390
return window_func
391391

@@ -406,8 +406,8 @@ def _get_window_indexer(self):
406406
Return an indexer class that will compute the window start and end bounds
407407
"""
408408
if self.is_freq_type:
409-
return libwindow_indexer.VariableWindowIndexer
410-
return libwindow_indexer.FixedWindowIndexer
409+
return window_indexers.VariableWindowIndexer
410+
return window_indexers.FixedWindowIndexer
411411

412412
def _apply(
413413
self,

pandas/io/excel/_base.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,9 @@
166166
result 'foo'
167167
168168
If a column or index contains an unparseable date, the entire column or
169-
index will be returned unaltered as an object data type. For non-standard
170-
datetime parsing, use ``pd.to_datetime`` after ``pd.read_excel``.
169+
index will be returned unaltered as an object data type. If you don`t want to
170+
parse some cells as date just change their type in Excel to "Text".
171+
For non-standard datetime parsing, use ``pd.to_datetime`` after ``pd.read_excel``.
171172
172173
Note: A fast-path exists for iso8601-formatted dates.
173174
date_parser : function, optional

pandas/io/excel/_util.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import warnings
2-
31
from pandas.compat._optional import import_optional_dependency
42

53
from pandas.core.dtypes.common import is_integer, is_list_like
@@ -136,16 +134,11 @@ def _maybe_convert_usecols(usecols):
136134
return usecols
137135

138136
if is_integer(usecols):
139-
warnings.warn(
140-
(
141-
"Passing in an integer for `usecols` has been "
142-
"deprecated. Please pass in a list of int from "
143-
"0 to `usecols` inclusive instead."
144-
),
145-
FutureWarning,
146-
stacklevel=2,
137+
raise ValueError(
138+
"Passing an integer for `usecols` is no longer supported. "
139+
"Please pass in a list of int from 0 to `usecols` "
140+
"inclusive instead."
147141
)
148-
return list(range(usecols + 1))
149142

150143
if isinstance(usecols, str):
151144
return _range2cols(usecols)

0 commit comments

Comments
 (0)