Skip to content

Commit 8b136bf

Browse files
committed
Merge remote-tracking branch 'upstream/master' into sparse-frame-accessor
2 parents 3005aed + 01d3dc2 commit 8b136bf

File tree

15 files changed

+183
-247
lines changed

15 files changed

+183
-247
lines changed

asv_bench/benchmarks/indexing.py

+1-13
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import numpy as np
44
import pandas.util.testing as tm
5-
from pandas import (Series, DataFrame, Panel, MultiIndex,
5+
from pandas import (Series, DataFrame, MultiIndex,
66
Int64Index, UInt64Index, Float64Index,
77
IntervalIndex, CategoricalIndex,
88
IndexSlice, concat, date_range)
@@ -277,18 +277,6 @@ def time_get_indexer_list(self, index):
277277
self.data.get_indexer(self.cat_list)
278278

279279

280-
class PanelIndexing(object):
281-
282-
def setup(self):
283-
with warnings.catch_warnings(record=True):
284-
self.p = Panel(np.random.randn(100, 100, 100))
285-
self.inds = range(0, 100, 10)
286-
287-
def time_subset(self):
288-
with warnings.catch_warnings(record=True):
289-
self.p.ix[(self.inds, self.inds, self.inds)]
290-
291-
292280
class MethodLookup(object):
293281

294282
def setup_cache(self):

asv_bench/benchmarks/join_merge.py

+1-27
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import warnings
21
import string
32

43
import numpy as np
54
import pandas.util.testing as tm
6-
from pandas import (DataFrame, Series, Panel, MultiIndex,
5+
from pandas import (DataFrame, Series, MultiIndex,
76
date_range, concat, merge, merge_asof)
87

98
try:
@@ -66,31 +65,6 @@ def time_concat_mixed_ndims(self, axis):
6665
concat(self.mixed_ndims, axis=axis)
6766

6867

69-
class ConcatPanels(object):
70-
71-
params = ([0, 1, 2], [True, False])
72-
param_names = ['axis', 'ignore_index']
73-
74-
def setup(self, axis, ignore_index):
75-
with warnings.catch_warnings(record=True):
76-
panel_c = Panel(np.zeros((10000, 200, 2),
77-
dtype=np.float32,
78-
order='C'))
79-
self.panels_c = [panel_c] * 20
80-
panel_f = Panel(np.zeros((10000, 200, 2),
81-
dtype=np.float32,
82-
order='F'))
83-
self.panels_f = [panel_f] * 20
84-
85-
def time_c_ordered(self, axis, ignore_index):
86-
with warnings.catch_warnings(record=True):
87-
concat(self.panels_c, axis=axis, ignore_index=ignore_index)
88-
89-
def time_f_ordered(self, axis, ignore_index):
90-
with warnings.catch_warnings(record=True):
91-
concat(self.panels_f, axis=axis, ignore_index=ignore_index)
92-
93-
9468
class ConcatDataFrames(object):
9569

9670
params = ([0, 1], [True, False])

asv_bench/benchmarks/panel_ctor.py

-55
This file was deleted.

asv_bench/benchmarks/panel_methods.py

-25
This file was deleted.

doc/source/user_guide/text.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ Since ``df.columns`` is an Index object, we can use the ``.str`` accessor
4646
df.columns.str.lower()
4747
4848
These string methods can then be used to clean up the columns as needed.
49-
Here we are removing leading and trailing white spaces, lower casing all names,
50-
and replacing any remaining white spaces with underscores:
49+
Here we are removing leading and trailing whitespaces, lower casing all names,
50+
and replacing any remaining whitespaces with underscores:
5151

5252
.. ipython:: python
5353
@@ -65,7 +65,7 @@ and replacing any remaining white spaces with underscores:
6565
``Series``.
6666

6767
Please note that a ``Series`` of type ``category`` with string ``.categories`` has
68-
some limitations in comparison of ``Series`` of type string (e.g. you can't add strings to
68+
some limitations in comparison to ``Series`` of type string (e.g. you can't add strings to
6969
each other: ``s + " " + s`` won't work if ``s`` is a ``Series`` of type ``category``). Also,
7070
``.str`` methods which operate on elements of type ``list`` are not available on such a
7171
``Series``.

doc/source/whatsnew/v0.25.0.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Other Enhancements
2727
- :meth:`DatetimeIndex.union` now supports the ``sort`` argument. The behaviour of the sort parameter matches that of :meth:`Index.union` (:issue:`24994`)
2828
- :meth:`DataFrame.rename` now supports the ``errors`` argument to raise errors when attempting to rename nonexistent keys (:issue:`13473`)
2929
- Added :ref:`api.frame.sparse` for working with a ``DataFrame`` whose values are sparse (:issue:`25681`)
30+
- :class:`RangeIndex` has gained :attr:`~RangeIndex.start`, :attr:`~RangeIndex.stop`, and :attr:`~RangeIndex.step` attributes (:issue:`25710`)
3031

3132
.. _whatsnew_0250.api_breaking:
3233

@@ -124,7 +125,7 @@ Bug Fixes
124125
~~~~~~~~~
125126
- Bug in :func:`to_datetime` which would raise an (incorrect) ``ValueError`` when called with a date far into the future and the ``format`` argument specified instead of raising ``OutOfBoundsDatetime`` (:issue:`23830`)
126127
- Bug in an error message in :meth:`DataFrame.plot`. Improved the error message if non-numerics are passed to :meth:`DataFrame.plot` (:issue:`25481`)
127-
-
128+
- Bug in error messages in :meth:`DataFrame.corr` and :meth:`Series.corr`. Added the possibility of using a callable. (:issue:`25729`)
128129

129130
Categorical
130131
^^^^^^^^^^^
@@ -225,6 +226,7 @@ I/O
225226
Plotting
226227
^^^^^^^^
227228

229+
- Fixed bug where :class:`api.extensions.ExtensionArray` could not be used in matplotlib plotting (:issue:`25587`)
228230
-
229231
-
230232
-

pandas/core/frame.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7089,8 +7089,8 @@ def corr(self, method='pearson', min_periods=1):
70897089
correl[j, i] = c
70907090
else:
70917091
raise ValueError("method must be either 'pearson', "
7092-
"'spearman', or 'kendall', '{method}' "
7093-
"was supplied".format(method=method))
7092+
"'spearman', 'kendall', or a callable, "
7093+
"'{method}' was supplied".format(method=method))
70947094

70957095
return self._constructor(correl, index=idx, columns=cols)
70967096

pandas/core/indexes/range.py

+26-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ class RangeIndex(Int64Index):
4848
4949
Attributes
5050
----------
51-
None
51+
start
52+
stop
53+
step
5254
5355
Methods
5456
-------
@@ -209,6 +211,29 @@ def _format_data(self, name=None):
209211
return None
210212

211213
# --------------------------------------------------------------------
214+
@property
215+
def start(self):
216+
"""
217+
The value of the `start` parameter (or ``0`` if this was not supplied)
218+
"""
219+
# GH 25710
220+
return self._start
221+
222+
@property
223+
def stop(self):
224+
"""
225+
The value of the `stop` parameter
226+
"""
227+
# GH 25710
228+
return self._stop
229+
230+
@property
231+
def step(self):
232+
"""
233+
The value of the `step` parameter (or ``1`` if this was not supplied)
234+
"""
235+
# GH 25710
236+
return self._step
212237

213238
@cache_readonly
214239
def nbytes(self):

pandas/core/series.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2159,8 +2159,8 @@ def corr(self, other, method='pearson', min_periods=None):
21592159
min_periods=min_periods)
21602160

21612161
raise ValueError("method must be either 'pearson', "
2162-
"'spearman', or 'kendall', '{method}' "
2163-
"was supplied".format(method=method))
2162+
"'spearman', 'kendall', or a callable, "
2163+
"'{method}' was supplied".format(method=method))
21642164

21652165
def cov(self, other, min_periods=None):
21662166
"""

pandas/plotting/_core.py

+20-7
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,12 @@ def _compute_plot_data(self):
365365
if is_empty:
366366
raise TypeError('no numeric data to plot')
367367

368+
# GH25587: cast ExtensionArray of pandas (IntegerArray, etc.) to
369+
# np.ndarray before plot.
370+
numeric_data = numeric_data.copy()
371+
for col in numeric_data:
372+
numeric_data[col] = np.asarray(numeric_data[col])
373+
368374
self.data = numeric_data
369375

370376
def _make_plot(self):
@@ -468,12 +474,20 @@ def _adorn_subplots(self):
468474
self.axes[0].set_title(self.title)
469475

470476
def _apply_axis_properties(self, axis, rot=None, fontsize=None):
471-
labels = axis.get_majorticklabels() + axis.get_minorticklabels()
472-
for label in labels:
473-
if rot is not None:
474-
label.set_rotation(rot)
475-
if fontsize is not None:
476-
label.set_fontsize(fontsize)
477+
""" Tick creation within matplotlib is reasonably expensive and is
478+
internally deferred until accessed as Ticks are created/destroyed
479+
multiple times per draw. It's therefore beneficial for us to avoid
480+
accessing unless we will act on the Tick.
481+
"""
482+
483+
if rot is not None or fontsize is not None:
484+
# rot=0 is a valid setting, hence the explicit None check
485+
labels = axis.get_majorticklabels() + axis.get_minorticklabels()
486+
for label in labels:
487+
if rot is not None:
488+
label.set_rotation(rot)
489+
if fontsize is not None:
490+
label.set_fontsize(fontsize)
477491

478492
@property
479493
def legend_title(self):
@@ -1794,7 +1808,6 @@ def _plot(data, x=None, y=None, subplots=False,
17941808
)
17951809
label_name = label_kw or data.columns
17961810
data.columns = label_name
1797-
17981811
plot_obj = klass(data, subplots=subplots, ax=ax, kind=kind, **kwds)
17991812

18001813
plot_obj.generate()

pandas/tests/frame/test_analytics.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,8 @@ def test_corr_cov_independent_index_column(self):
332332
def test_corr_invalid_method(self):
333333
# GH 22298
334334
df = pd.DataFrame(np.random.normal(size=(10, 2)))
335-
msg = ("method must be either 'pearson', 'spearman', "
336-
"or 'kendall'")
335+
msg = ("method must be either 'pearson', "
336+
"'spearman', 'kendall', or a callable, ")
337337
with pytest.raises(ValueError, match=msg):
338338
df.corr(method="____")
339339

0 commit comments

Comments
 (0)