Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into sparse-frame-acce…
Browse files Browse the repository at this point in the history
…ssor
  • Loading branch information
TomAugspurger committed Mar 15, 2019
2 parents 3005aed + 01d3dc2 commit 8b136bf
Show file tree
Hide file tree
Showing 15 changed files with 183 additions and 247 deletions.
14 changes: 1 addition & 13 deletions asv_bench/benchmarks/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import numpy as np
import pandas.util.testing as tm
from pandas import (Series, DataFrame, Panel, MultiIndex,
from pandas import (Series, DataFrame, MultiIndex,
Int64Index, UInt64Index, Float64Index,
IntervalIndex, CategoricalIndex,
IndexSlice, concat, date_range)
Expand Down Expand Up @@ -277,18 +277,6 @@ def time_get_indexer_list(self, index):
self.data.get_indexer(self.cat_list)


class PanelIndexing(object):

def setup(self):
with warnings.catch_warnings(record=True):
self.p = Panel(np.random.randn(100, 100, 100))
self.inds = range(0, 100, 10)

def time_subset(self):
with warnings.catch_warnings(record=True):
self.p.ix[(self.inds, self.inds, self.inds)]


class MethodLookup(object):

def setup_cache(self):
Expand Down
28 changes: 1 addition & 27 deletions asv_bench/benchmarks/join_merge.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import warnings
import string

import numpy as np
import pandas.util.testing as tm
from pandas import (DataFrame, Series, Panel, MultiIndex,
from pandas import (DataFrame, Series, MultiIndex,
date_range, concat, merge, merge_asof)

try:
Expand Down Expand Up @@ -66,31 +65,6 @@ def time_concat_mixed_ndims(self, axis):
concat(self.mixed_ndims, axis=axis)


class ConcatPanels(object):

params = ([0, 1, 2], [True, False])
param_names = ['axis', 'ignore_index']

def setup(self, axis, ignore_index):
with warnings.catch_warnings(record=True):
panel_c = Panel(np.zeros((10000, 200, 2),
dtype=np.float32,
order='C'))
self.panels_c = [panel_c] * 20
panel_f = Panel(np.zeros((10000, 200, 2),
dtype=np.float32,
order='F'))
self.panels_f = [panel_f] * 20

def time_c_ordered(self, axis, ignore_index):
with warnings.catch_warnings(record=True):
concat(self.panels_c, axis=axis, ignore_index=ignore_index)

def time_f_ordered(self, axis, ignore_index):
with warnings.catch_warnings(record=True):
concat(self.panels_f, axis=axis, ignore_index=ignore_index)


class ConcatDataFrames(object):

params = ([0, 1], [True, False])
Expand Down
55 changes: 0 additions & 55 deletions asv_bench/benchmarks/panel_ctor.py

This file was deleted.

25 changes: 0 additions & 25 deletions asv_bench/benchmarks/panel_methods.py

This file was deleted.

6 changes: 3 additions & 3 deletions doc/source/user_guide/text.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ Since ``df.columns`` is an Index object, we can use the ``.str`` accessor
df.columns.str.lower()
These string methods can then be used to clean up the columns as needed.
Here we are removing leading and trailing white spaces, lower casing all names,
and replacing any remaining white spaces with underscores:
Here we are removing leading and trailing whitespaces, lower casing all names,
and replacing any remaining whitespaces with underscores:

.. ipython:: python
Expand All @@ -65,7 +65,7 @@ and replacing any remaining white spaces with underscores:
``Series``.

Please note that a ``Series`` of type ``category`` with string ``.categories`` has
some limitations in comparison of ``Series`` of type string (e.g. you can't add strings to
some limitations in comparison to ``Series`` of type string (e.g. you can't add strings to
each other: ``s + " " + s`` won't work if ``s`` is a ``Series`` of type ``category``). Also,
``.str`` methods which operate on elements of type ``list`` are not available on such a
``Series``.
Expand Down
4 changes: 3 additions & 1 deletion doc/source/whatsnew/v0.25.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Other Enhancements
- :meth:`DatetimeIndex.union` now supports the ``sort`` argument. The behaviour of the sort parameter matches that of :meth:`Index.union` (:issue:`24994`)
- :meth:`DataFrame.rename` now supports the ``errors`` argument to raise errors when attempting to rename nonexistent keys (:issue:`13473`)
- Added :ref:`api.frame.sparse` for working with a ``DataFrame`` whose values are sparse (:issue:`25681`)
- :class:`RangeIndex` has gained :attr:`~RangeIndex.start`, :attr:`~RangeIndex.stop`, and :attr:`~RangeIndex.step` attributes (:issue:`25710`)

.. _whatsnew_0250.api_breaking:

Expand Down Expand Up @@ -124,7 +125,7 @@ Bug Fixes
~~~~~~~~~
- 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`)
- Bug in an error message in :meth:`DataFrame.plot`. Improved the error message if non-numerics are passed to :meth:`DataFrame.plot` (:issue:`25481`)
-
- Bug in error messages in :meth:`DataFrame.corr` and :meth:`Series.corr`. Added the possibility of using a callable. (:issue:`25729`)

Categorical
^^^^^^^^^^^
Expand Down Expand Up @@ -225,6 +226,7 @@ I/O
Plotting
^^^^^^^^

- Fixed bug where :class:`api.extensions.ExtensionArray` could not be used in matplotlib plotting (:issue:`25587`)
-
-
-
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -7089,8 +7089,8 @@ def corr(self, method='pearson', min_periods=1):
correl[j, i] = c
else:
raise ValueError("method must be either 'pearson', "
"'spearman', or 'kendall', '{method}' "
"was supplied".format(method=method))
"'spearman', 'kendall', or a callable, "
"'{method}' was supplied".format(method=method))

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

Expand Down
27 changes: 26 additions & 1 deletion pandas/core/indexes/range.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ class RangeIndex(Int64Index):
Attributes
----------
None
start
stop
step
Methods
-------
Expand Down Expand Up @@ -209,6 +211,29 @@ def _format_data(self, name=None):
return None

# --------------------------------------------------------------------
@property
def start(self):
"""
The value of the `start` parameter (or ``0`` if this was not supplied)
"""
# GH 25710
return self._start

@property
def stop(self):
"""
The value of the `stop` parameter
"""
# GH 25710
return self._stop

@property
def step(self):
"""
The value of the `step` parameter (or ``1`` if this was not supplied)
"""
# GH 25710
return self._step

@cache_readonly
def nbytes(self):
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2159,8 +2159,8 @@ def corr(self, other, method='pearson', min_periods=None):
min_periods=min_periods)

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

def cov(self, other, min_periods=None):
"""
Expand Down
27 changes: 20 additions & 7 deletions pandas/plotting/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,12 @@ def _compute_plot_data(self):
if is_empty:
raise TypeError('no numeric data to plot')

# GH25587: cast ExtensionArray of pandas (IntegerArray, etc.) to
# np.ndarray before plot.
numeric_data = numeric_data.copy()
for col in numeric_data:
numeric_data[col] = np.asarray(numeric_data[col])

self.data = numeric_data

def _make_plot(self):
Expand Down Expand Up @@ -468,12 +474,20 @@ def _adorn_subplots(self):
self.axes[0].set_title(self.title)

def _apply_axis_properties(self, axis, rot=None, fontsize=None):
labels = axis.get_majorticklabels() + axis.get_minorticklabels()
for label in labels:
if rot is not None:
label.set_rotation(rot)
if fontsize is not None:
label.set_fontsize(fontsize)
""" Tick creation within matplotlib is reasonably expensive and is
internally deferred until accessed as Ticks are created/destroyed
multiple times per draw. It's therefore beneficial for us to avoid
accessing unless we will act on the Tick.
"""

if rot is not None or fontsize is not None:
# rot=0 is a valid setting, hence the explicit None check
labels = axis.get_majorticklabels() + axis.get_minorticklabels()
for label in labels:
if rot is not None:
label.set_rotation(rot)
if fontsize is not None:
label.set_fontsize(fontsize)

@property
def legend_title(self):
Expand Down Expand Up @@ -1794,7 +1808,6 @@ def _plot(data, x=None, y=None, subplots=False,
)
label_name = label_kw or data.columns
data.columns = label_name

plot_obj = klass(data, subplots=subplots, ax=ax, kind=kind, **kwds)

plot_obj.generate()
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/frame/test_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@ def test_corr_cov_independent_index_column(self):
def test_corr_invalid_method(self):
# GH 22298
df = pd.DataFrame(np.random.normal(size=(10, 2)))
msg = ("method must be either 'pearson', 'spearman', "
"or 'kendall'")
msg = ("method must be either 'pearson', "
"'spearman', 'kendall', or a callable, ")
with pytest.raises(ValueError, match=msg):
df.corr(method="____")

Expand Down
Loading

0 comments on commit 8b136bf

Please sign in to comment.