Skip to content

Commit ade2efe

Browse files
author
luke
committed
Merge branch 'bug-agg-nonunique-col' of https://github.com/luke396/pandas into bug-agg-nonunique-col
2 parents e533f43 + d592fdf commit ade2efe

40 files changed

+258
-146
lines changed

doc/source/development/contributing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ If using :ref:`mamba <contributing.mamba>`, do::
349349
If using :ref:`pip <contributing.pip>` , do::
350350

351351
# activate the virtual environment based on your platform
352-
pythom -m pip install --upgrade -r requirements-dev.txt
352+
python -m pip install --upgrade -r requirements-dev.txt
353353

354354
Tips for a successful pull request
355355
==================================

doc/source/user_guide/basics.rst

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -329,16 +329,6 @@ You can test if a pandas object is empty, via the :attr:`~DataFrame.empty` prope
329329
df.empty
330330
pd.DataFrame(columns=list("ABC")).empty
331331
332-
To evaluate single-element pandas objects in a boolean context, use the method
333-
:meth:`~DataFrame.bool`:
334-
335-
.. ipython:: python
336-
337-
pd.Series([True]).bool()
338-
pd.Series([False]).bool()
339-
pd.DataFrame([[True]]).bool()
340-
pd.DataFrame([[False]]).bool()
341-
342332
.. warning::
343333

344334
You might be tempted to do the following:

doc/source/user_guide/gotchas.rst

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,6 @@ Below is how to check if any of the values are ``True``:
121121
if pd.Series([False, True, False]).any():
122122
print("I am any")
123123
124-
To evaluate single-element pandas objects in a boolean context, use the method
125-
:meth:`~DataFrame.bool`:
126-
127-
.. ipython:: python
128-
129-
pd.Series([True]).bool()
130-
pd.Series([False]).bool()
131-
pd.DataFrame([[True]]).bool()
132-
pd.DataFrame([[False]]).bool()
133-
134124
Bitwise boolean
135125
~~~~~~~~~~~~~~~
136126

doc/source/whatsnew/v0.13.0.rst

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,16 @@ API changes
153153
154154
Added the ``.bool()`` method to ``NDFrame`` objects to facilitate evaluating of single-element boolean Series:
155155

156-
.. ipython:: python
156+
.. code-block:: python
157157
158-
pd.Series([True]).bool()
159-
pd.Series([False]).bool()
160-
pd.DataFrame([[True]]).bool()
161-
pd.DataFrame([[False]]).bool()
158+
>>> pd.Series([True]).bool()
159+
True
160+
>>> pd.Series([False]).bool()
161+
False
162+
>>> pd.DataFrame([[True]]).bool()
163+
True
164+
>>> pd.DataFrame([[False]]).bool()
165+
False
162166
163167
- All non-Index NDFrames (``Series``, ``DataFrame``, ``Panel``, ``Panel4D``,
164168
``SparsePanel``, etc.), now support the entire set of arithmetic operators

doc/source/whatsnew/v2.1.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ Deprecations
125125
- Deprecated the 'axis' keyword in :meth:`.GroupBy.idxmax`, :meth:`.GroupBy.idxmin`, :meth:`.GroupBy.fillna`, :meth:`.GroupBy.take`, :meth:`.GroupBy.skew`, :meth:`.GroupBy.rank`, :meth:`.GroupBy.cumprod`, :meth:`.GroupBy.cumsum`, :meth:`.GroupBy.cummax`, :meth:`.GroupBy.cummin`, :meth:`.GroupBy.pct_change`, :meth:`GroupBy.diff`, :meth:`.GroupBy.shift`, and :meth:`DataFrameGroupBy.corrwith`; for ``axis=1`` operate on the underlying :class:`DataFrame` instead (:issue:`50405`, :issue:`51046`)
126126
- Deprecated passing a dictionary to :meth:`.SeriesGroupBy.agg`; pass a list of aggregations instead (:issue:`50684`)
127127
- Deprecated logical operations (``|``, ``&``, ``^``) between pandas objects and dtype-less sequences (e.g. ``list``, ``tuple``), wrap a sequence in a :class:`Series` or numpy array before operating instead (:issue:`51521`)
128+
- Deprecated the methods :meth:`Series.bool` and :meth:`DataFrame.bool` (:issue:`51749`)
128129
- Deprecated :meth:`DataFrame.swapaxes` and :meth:`Series.swapaxes`, use :meth:`DataFrame.transpose` or :meth:`Series.transpose` instead (:issue:`51946`)
129130
- Deprecated parameter ``convert_type`` in :meth:`Series.apply` (:issue:`52140`)
130131
-

pandas/_libs/tslibs/offsets.pyx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,18 +1350,18 @@ class DateOffset(RelativeDeltaOffset, metaclass=OffsetMeta):
13501350
valid dates. For example, Bday(2) can be added to a date to move
13511351
it two business days forward. If the date does not start on a
13521352
valid date, first it is moved to a valid date. Thus pseudo code
1353-
is:
1353+
is::
13541354
1355-
def __add__(date):
1356-
date = rollback(date) # does nothing if date is valid
1357-
return date + <n number of periods>
1355+
def __add__(date):
1356+
date = rollback(date) # does nothing if date is valid
1357+
return date + <n number of periods>
13581358
13591359
When a date offset is created for a negative number of periods,
1360-
the date is first rolled forward. The pseudo code is:
1360+
the date is first rolled forward. The pseudo code is::
13611361
1362-
def __add__(date):
1363-
date = rollforward(date) # does nothing is date is valid
1364-
return date + <n number of periods>
1362+
def __add__(date):
1363+
date = rollforward(date) # does nothing if date is valid
1364+
return date + <n number of periods>
13651365
13661366
Zero presents a problem. Should it roll forward or back? We
13671367
arbitrarily have it rollforward:

pandas/_libs/tslibs/timestamps.pyx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,6 +1293,9 @@ class Timestamp(_Timestamp):
12931293
Unit used for conversion if ts_input is of type int or float. The
12941294
valid values are 'D', 'h', 'm', 's', 'ms', 'us', and 'ns'. For
12951295
example, 's' means seconds and 'ms' means milliseconds.
1296+
1297+
For float inputs, the result will be stored in nanoseconds, and
1298+
the unit attribute will be set as ``'ns'``.
12961299
fold : {0, 1}, default None, keyword-only
12971300
Due to daylight saving time, one wall clock time can occur twice
12981301
when shifting from summer to winter time; fold describes whether the

pandas/conftest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ def pytest_collection_modifyitems(items, config) -> None:
137137
ignored_doctest_warnings = [
138138
# Docstring divides by zero to show behavior difference
139139
("missing.mask_zero_div_zero", "divide by zero encountered"),
140+
(
141+
"pandas.core.generic.NDFrame.bool",
142+
"(Series|DataFrame).bool is now deprecated and will be removed "
143+
"in future version of pandas",
144+
),
140145
]
141146

142147
for item in items:

pandas/core/algorithms.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ def value_counts(
838838
if bins is not None:
839839
from pandas.core.reshape.tile import cut
840840

841-
values = Series(values)
841+
values = Series(values, copy=False)
842842
try:
843843
ii = cut(values, bins, include_lowest=True)
844844
except TypeError as err:
@@ -861,7 +861,7 @@ def value_counts(
861861
else:
862862
if is_extension_array_dtype(values):
863863
# handle Categorical and sparse,
864-
result = Series(values)._values.value_counts(dropna=dropna)
864+
result = Series(values, copy=False)._values.value_counts(dropna=dropna)
865865
result.name = name
866866
result.index.name = index_name
867867
counts = result._values
@@ -893,7 +893,7 @@ def value_counts(
893893
idx = idx.astype(object)
894894
idx.name = index_name
895895

896-
result = Series(counts, index=idx, name=name)
896+
result = Series(counts, index=idx, name=name, copy=False)
897897

898898
if sort:
899899
result = result.sort_values(ascending=ascending)

pandas/core/arrays/_mixins.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ def value_counts(self, dropna: bool = True) -> Series:
445445

446446
index_arr = self._from_backing_data(np.asarray(result.index._data))
447447
index = Index(index_arr, name=result.index.name)
448-
return Series(result._values, index=index, name=result.name)
448+
return Series(result._values, index=index, name=result.name, copy=False)
449449

450450
def _quantile(
451451
self,

0 commit comments

Comments
 (0)