Skip to content

Commit 739bd69

Browse files
committed
Merge branch 'master' of https://github.com/pandas-dev/pandas into Tdtype
2 parents e0e75d7 + 9dc4d71 commit 739bd69

File tree

21 files changed

+338
-70
lines changed

21 files changed

+338
-70
lines changed

doc/source/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@
315315
import numpy as np
316316
import pandas as pd
317317
318-
randn = np.random.randn
319318
np.random.seed(123456)
320319
np.set_printoptions(precision=4, suppress=True)
321320
pd.options.display.max_rows = 15

doc/source/whatsnew/index.rst

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

27+
v0.25.2
2728
v0.25.1
2829
v0.25.0
2930

doc/source/whatsnew/v0.10.0.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ Here is a taste of what to expect.
498498

499499
.. code-block:: ipython
500500
501-
In [58]: p4d = Panel4D(randn(2, 2, 5, 4),
501+
In [58]: p4d = Panel4D(np.random.randn(2, 2, 5, 4),
502502
....: labels=['Label1','Label2'],
503503
....: items=['Item1', 'Item2'],
504504
....: major_axis=date_range('1/1/2000', periods=5),

doc/source/whatsnew/v0.25.1.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ Plotting
8585
Groupby/resample/rolling
8686
^^^^^^^^^^^^^^^^^^^^^^^^
8787

88+
- Fixed regression in :meth:`pands.core.groupby.DataFrameGroupBy.quantile` raising when multiple quantiles are given (:issue:`27526`)
8889
- Bug in :meth:`pandas.core.groupby.DataFrameGroupBy.transform` where applying a timezone conversion lambda function would drop timezone information (:issue:`27496`)
8990
- Bug in :meth:`pandas.core.groupby.GroupBy.nth` where ``observed=False`` was being ignored for Categorical groupers (:issue:`26385`)
9091
- Bug in windowing over read-only arrays (:issue:`27766`)
@@ -94,6 +95,7 @@ Reshaping
9495
^^^^^^^^^
9596

9697
- A ``KeyError`` is now raised if ``.unstack()`` is called on a :class:`Series` or :class:`DataFrame` with a flat :class:`Index` passing a name which is not the correct one (:issue:`18303`)
98+
- Bug :meth:`merge_asof` could not merge :class:`Timedelta` objects when passing `tolerance` kwarg (:issue:`27642`)
9799
- Bug in :meth:`DataFrame.crosstab` when ``margins`` set to ``True`` and ``normalize`` is not ``False``, an error is raised. (:issue:`27500`)
98100
- :meth:`DataFrame.join` now suppresses the ``FutureWarning`` when the sort parameter is specified (:issue:`21952`)
99101
- Bug in :meth:`DataFrame.join` raising with readonly arrays (:issue:`27943`)
@@ -107,6 +109,7 @@ Other
107109
^^^^^
108110

109111
- Bug in :meth:`Series.replace` and :meth:`DataFrame.replace` when replacing timezone-aware timestamps using a dict-like replacer (:issue:`27720`)
112+
- Bug in :meth:`Series.rename` when using a custom type indexer. Now any value that isn't callable or dict-like is treated as a scalar. (:issue:`27814`)
110113

111114
.. _whatsnew_0.251.contributors:
112115

doc/source/whatsnew/v0.25.2.rst

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
.. _whatsnew_0252:
2+
3+
What's new in 0.25.2 (October XX, 2019)
4+
---------------------------------------
5+
6+
These are the changes in pandas 0.25.2. See :ref:`release` for a full changelog
7+
including other versions of pandas.
8+
9+
.. _whatsnew_0252.bug_fixes:
10+
11+
Bug fixes
12+
~~~~~~~~~
13+
14+
Categorical
15+
^^^^^^^^^^^
16+
17+
-
18+
19+
Datetimelike
20+
^^^^^^^^^^^^
21+
22+
-
23+
-
24+
-
25+
26+
Timezones
27+
^^^^^^^^^
28+
29+
-
30+
31+
Numeric
32+
^^^^^^^
33+
34+
-
35+
-
36+
-
37+
-
38+
39+
Conversion
40+
^^^^^^^^^^
41+
42+
-
43+
44+
Interval
45+
^^^^^^^^
46+
47+
-
48+
49+
Indexing
50+
^^^^^^^^
51+
52+
-
53+
-
54+
-
55+
-
56+
57+
Missing
58+
^^^^^^^
59+
60+
-
61+
62+
I/O
63+
^^^
64+
65+
-
66+
-
67+
-
68+
69+
Plotting
70+
^^^^^^^^
71+
72+
-
73+
-
74+
-
75+
76+
Groupby/resample/rolling
77+
^^^^^^^^^^^^^^^^^^^^^^^^
78+
79+
-
80+
-
81+
-
82+
-
83+
-
84+
85+
Reshaping
86+
^^^^^^^^^
87+
88+
-
89+
-
90+
-
91+
-
92+
-
93+
94+
Sparse
95+
^^^^^^
96+
97+
-
98+
99+
Other
100+
^^^^^
101+
102+
-
103+
-
104+
105+
.. _whatsnew_0.252.contributors:
106+
107+
Contributors
108+
~~~~~~~~~~~~
109+
110+
.. contributors:: v0.25.1..HEAD

pandas/core/arrays/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ def fillna(self, value=None, method=None, limit=None):
514514

515515
def dropna(self):
516516
"""
517-
Return ExtensionArray without NA values
517+
Return ExtensionArray without NA values.
518518
519519
Returns
520520
-------
@@ -957,7 +957,7 @@ def _concat_same_type(
957957
cls, to_concat: Sequence[ABCExtensionArray]
958958
) -> ABCExtensionArray:
959959
"""
960-
Concatenate multiple array
960+
Concatenate multiple array.
961961
962962
Parameters
963963
----------

pandas/core/arrays/datetimes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,7 @@ def tz_localize(self, tz, ambiguous="raise", nonexistent="raise", errors=None):
11581158
def to_pydatetime(self):
11591159
"""
11601160
Return Datetime Array/Index as object ndarray of datetime.datetime
1161-
objects
1161+
objects.
11621162
11631163
Returns
11641164
-------
@@ -1283,7 +1283,7 @@ def to_perioddelta(self, freq):
12831283
"""
12841284
Calculate TimedeltaArray of difference between index
12851285
values and index converted to PeriodArray at specified
1286-
freq. Used for vectorized offsets
1286+
freq. Used for vectorized offsets.
12871287
12881288
Parameters
12891289
----------

pandas/core/arrays/period.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ def __array__(self, dtype=None):
426426
@property
427427
def is_leap_year(self):
428428
"""
429-
Logical indicating if the date belongs to a leap year
429+
Logical indicating if the date belongs to a leap year.
430430
"""
431431
return isleapyear_arr(np.asarray(self.year))
432432

pandas/core/frame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3098,7 +3098,7 @@ def _ensure_valid_index(self, value):
30983098
passed value.
30993099
"""
31003100
# GH5632, make sure that we are a Series convertible
3101-
if not len(self.index) and is_list_like(value):
3101+
if not len(self.index) and is_list_like(value) and len(value):
31023102
try:
31033103
value = Series(value)
31043104
except (ValueError, NotImplementedError, TypeError):

pandas/core/groupby/groupby.py

Lines changed: 58 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,6 +1874,7 @@ def quantile(self, q=0.5, interpolation="linear"):
18741874
a 2.0
18751875
b 3.0
18761876
"""
1877+
from pandas import concat
18771878

18781879
def pre_processor(vals: np.ndarray) -> Tuple[np.ndarray, Optional[Type]]:
18791880
if is_object_dtype(vals):
@@ -1901,18 +1902,57 @@ def post_processor(vals: np.ndarray, inference: Optional[Type]) -> np.ndarray:
19011902

19021903
return vals
19031904

1904-
return self._get_cythonized_result(
1905-
"group_quantile",
1906-
self.grouper,
1907-
aggregate=True,
1908-
needs_values=True,
1909-
needs_mask=True,
1910-
cython_dtype=np.float64,
1911-
pre_processing=pre_processor,
1912-
post_processing=post_processor,
1913-
q=q,
1914-
interpolation=interpolation,
1915-
)
1905+
if is_scalar(q):
1906+
return self._get_cythonized_result(
1907+
"group_quantile",
1908+
self.grouper,
1909+
aggregate=True,
1910+
needs_values=True,
1911+
needs_mask=True,
1912+
cython_dtype=np.float64,
1913+
pre_processing=pre_processor,
1914+
post_processing=post_processor,
1915+
q=q,
1916+
interpolation=interpolation,
1917+
)
1918+
else:
1919+
results = [
1920+
self._get_cythonized_result(
1921+
"group_quantile",
1922+
self.grouper,
1923+
aggregate=True,
1924+
needs_values=True,
1925+
needs_mask=True,
1926+
cython_dtype=np.float64,
1927+
pre_processing=pre_processor,
1928+
post_processing=post_processor,
1929+
q=qi,
1930+
interpolation=interpolation,
1931+
)
1932+
for qi in q
1933+
]
1934+
result = concat(results, axis=0, keys=q)
1935+
# fix levels to place quantiles on the inside
1936+
# TODO(GH-10710): Ideally, we could write this as
1937+
# >>> result.stack(0).loc[pd.IndexSlice[:, ..., q], :]
1938+
# but this hits https://github.com/pandas-dev/pandas/issues/10710
1939+
# which doesn't reorder the list-like `q` on the inner level.
1940+
order = np.roll(list(range(result.index.nlevels)), -1)
1941+
result = result.reorder_levels(order)
1942+
result = result.reindex(q, level=-1)
1943+
1944+
# fix order.
1945+
hi = len(q) * self.ngroups
1946+
arr = np.arange(0, hi, self.ngroups)
1947+
arrays = []
1948+
1949+
for i in range(self.ngroups):
1950+
arr = arr + i
1951+
arrays.append(arr)
1952+
1953+
indices = np.concatenate(arrays)
1954+
assert len(indices) == len(result)
1955+
return result.take(indices)
19161956

19171957
@Substitution(name="groupby")
19181958
def ngroup(self, ascending=True):
@@ -2330,8 +2370,9 @@ def head(self, n=5):
23302370
"""
23312371
Return first n rows of each group.
23322372
2333-
Essentially equivalent to ``.apply(lambda x: x.head(n))``,
2334-
except ignores as_index flag.
2373+
Similar to ``.apply(lambda x: x.head(n))``, but it returns a subset of rows
2374+
from the original DataFrame with original index and order preserved
2375+
(``as_index`` flag is ignored).
23352376
23362377
Returns
23372378
-------
@@ -2342,10 +2383,6 @@ def head(self, n=5):
23422383
23432384
>>> df = pd.DataFrame([[1, 2], [1, 4], [5, 6]],
23442385
... columns=['A', 'B'])
2345-
>>> df.groupby('A', as_index=False).head(1)
2346-
A B
2347-
0 1 2
2348-
2 5 6
23492386
>>> df.groupby('A').head(1)
23502387
A B
23512388
0 1 2
@@ -2361,8 +2398,9 @@ def tail(self, n=5):
23612398
"""
23622399
Return last n rows of each group.
23632400
2364-
Essentially equivalent to ``.apply(lambda x: x.tail(n))``,
2365-
except ignores as_index flag.
2401+
Similar to ``.apply(lambda x: x.tail(n))``, but it returns a subset of rows
2402+
from the original DataFrame with original index and order preserved
2403+
(``as_index`` flag is ignored).
23662404
23672405
Returns
23682406
-------
@@ -2377,10 +2415,6 @@ def tail(self, n=5):
23772415
A B
23782416
1 a 2
23792417
3 b 2
2380-
>>> df.groupby('A').head(1)
2381-
A B
2382-
0 a 1
2383-
2 b 1
23842418
"""
23852419
self._reset_group_selection()
23862420
mask = self._cumcount_array(ascending=False) < n

pandas/core/indexes/datetimes.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ def _get_time_micros(self):
661661
def to_series(self, keep_tz=None, index=None, name=None):
662662
"""
663663
Create a Series with both index and values equal to the index keys
664-
useful with map for returning an indexer based on an index
664+
useful with map for returning an indexer based on an index.
665665
666666
Parameters
667667
----------
@@ -687,10 +687,10 @@ def to_series(self, keep_tz=None, index=None, name=None):
687687
behaviour and silence the warning.
688688
689689
index : Index, optional
690-
index of resulting Series. If None, defaults to original index
691-
name : string, optional
692-
name of resulting Series. If None, defaults to name of original
693-
index
690+
Index of resulting Series. If None, defaults to original index.
691+
name : str, optional
692+
Name of resulting Series. If None, defaults to name of original
693+
index.
694694
695695
Returns
696696
-------
@@ -735,7 +735,7 @@ def to_series(self, keep_tz=None, index=None, name=None):
735735

736736
def snap(self, freq="S"):
737737
"""
738-
Snap time stamps to nearest occurring frequency
738+
Snap time stamps to nearest occurring frequency.
739739
740740
Returns
741741
-------

pandas/core/indexes/multi.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,7 +1250,7 @@ def _set_names(self, names, level=None, validate=True):
12501250
self.levels[l].rename(name, inplace=True)
12511251

12521252
names = property(
1253-
fset=_set_names, fget=_get_names, doc="""\nNames of levels in MultiIndex\n"""
1253+
fset=_set_names, fget=_get_names, doc="""\nNames of levels in MultiIndex.\n"""
12541254
)
12551255

12561256
@Appender(_index_shared_docs["_get_grouper_for_level"])
@@ -1762,7 +1762,7 @@ def is_all_dates(self):
17621762

17631763
def is_lexsorted(self):
17641764
"""
1765-
Return True if the codes are lexicographically sorted
1765+
Return True if the codes are lexicographically sorted.
17661766
17671767
Returns
17681768
-------
@@ -2246,7 +2246,7 @@ def swaplevel(self, i=-2, j=-1):
22462246

22472247
def reorder_levels(self, order):
22482248
"""
2249-
Rearrange levels using input order. May not drop or duplicate levels
2249+
Rearrange levels using input order. May not drop or duplicate levels.
22502250
22512251
Parameters
22522252
----------

0 commit comments

Comments
 (0)