Skip to content

Commit 2870163

Browse files
committed
Merge branch 'master' into feature/groupby-repr-ellipses-1135
2 parents 8f30d07 + 74a9ae3 commit 2870163

19 files changed

+79
-51
lines changed

doc/source/getting_started/10min.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ Display the index, columns:
103103
df.columns
104104
105105
:meth:`DataFrame.to_numpy` gives a NumPy representation of the underlying data.
106-
Note that his can be an expensive operation when your :class:`DataFrame` has
106+
Note that this can be an expensive operation when your :class:`DataFrame` has
107107
columns with different data types, which comes down to a fundamental difference
108108
between pandas and NumPy: **NumPy arrays have one dtype for the entire array,
109109
while pandas DataFrames have one dtype per column**. When you call

doc/source/getting_started/dsintro.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -576,14 +576,14 @@ To write code compatible with all versions of Python, split the assignment in tw
576576
577577
.. warning::
578578

579-
Dependent assignment maybe subtly change the behavior of your code between
579+
Dependent assignment may subtly change the behavior of your code between
580580
Python 3.6 and older versions of Python.
581581

582-
If you wish write code that supports versions of python before and after 3.6,
582+
If you wish to write code that supports versions of python before and after 3.6,
583583
you'll need to take care when passing ``assign`` expressions that
584584

585-
* Updating an existing column
586-
* Referring to the newly updated column in the same ``assign``
585+
* Update an existing column
586+
* Refer to the newly updated column in the same ``assign``
587587

588588
For example, we'll update column "A" and then refer to it when creating "B".
589589

@@ -665,8 +665,8 @@ row-wise. For example:
665665
666666
df - df.iloc[0]
667667
668-
In the special case of working with time series data, and the DataFrame index
669-
also contains dates, the broadcasting will be column-wise:
668+
In the special case of working with time series data, if the DataFrame index
669+
contains dates, the broadcasting will be column-wise:
670670

671671
.. ipython:: python
672672
:okwarning:

doc/source/whatsnew/v0.24.2.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Fixed Regressions
3030
- Fixed regression in :class:`TimedeltaIndex` where ``np.sum(index)`` incorrectly returned a zero-dimensional object instead of a scalar (:issue:`25282`)
3131
- Fixed regression in ``IntervalDtype`` construction where passing an incorrect string with 'Interval' as a prefix could result in a ``RecursionError``. (:issue:`25338`)
3232
- Fixed regression in :class:`Categorical`, where constructing it from a categorical ``Series`` and an explicit ``categories=`` that differed from that in the ``Series`` created an invalid object which could trigger segfaults. (:issue:`25318`)
33+
- Fixed pip installing from source into an environment without NumPy (:issue:`25193`)
3334

3435
.. _whatsnew_0242.enhancements:
3536

doc/source/whatsnew/v0.25.0.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ Missing
196196
^^^^^^^
197197

198198
- Fixed misleading exception message in :meth:`Series.missing` if argument ``order`` is required, but omitted (:issue:`10633`, :issue:`24014`).
199-
-
199+
- Fixed class type displayed in exception message in :meth:`DataFrame.dropna` if invalid ``axis`` parameter passed (:issue:`25555`)
200200
-
201201

202202
MultiIndex

pandas/core/generic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ def _get_axis_number(cls, axis):
358358
except KeyError:
359359
pass
360360
raise ValueError('No axis named {0} for object type {1}'
361-
.format(axis, type(cls)))
361+
.format(axis, cls))
362362

363363
@classmethod
364364
def _get_axis_name(cls, axis):
@@ -372,7 +372,7 @@ def _get_axis_name(cls, axis):
372372
except KeyError:
373373
pass
374374
raise ValueError('No axis named {0} for object type {1}'
375-
.format(axis, type(cls)))
375+
.format(axis, cls))
376376

377377
def _get_axis(self, axis):
378378
name = self._get_axis_name(axis)

pandas/io/formats/style.py

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -576,10 +576,10 @@ def apply(self, func, axis=0, subset=None, **kwargs):
576576
on ``axis``), and return an object with the same shape.
577577
Must return a DataFrame with identical index and
578578
column labels when ``axis=None``
579-
axis : int, str or None
580-
apply to each column (``axis=0`` or ``'index'``)
581-
or to each row (``axis=1`` or ``'columns'``) or
582-
to the entire DataFrame at once with ``axis=None``
579+
axis : {0 or 'index', 1 or 'columns', None}, default 0
580+
apply to each column (``axis=0`` or ``'index'``), to each row
581+
(``axis=1`` or ``'columns'``), or to the entire DataFrame at once
582+
with ``axis=None``.
583583
subset : IndexSlice
584584
a valid indexer to limit ``data`` to *before* applying the
585585
function. Consider using a pandas.IndexSlice
@@ -894,10 +894,12 @@ def background_gradient(self, cmap='PuBu', low=0, high=0, axis=0,
894894
matplotlib colormap
895895
low, high : float
896896
compress the range by these values.
897-
axis : int or str
898-
1 or 'columns' for columnwise, 0 or 'index' for rowwise
897+
axis : {0 or 'index', 1 or 'columns', None}, default 0
898+
apply to each column (``axis=0`` or ``'index'``), to each row
899+
(``axis=1`` or ``'columns'``), or to the entire DataFrame at once
900+
with ``axis=None``.
899901
subset : IndexSlice
900-
a valid slice for ``data`` to limit the style application to
902+
a valid slice for ``data`` to limit the style application to.
901903
text_color_threshold : float or int
902904
luminance threshold for determining text color. Facilitates text
903905
visibility across varying background colors. From 0 to 1.
@@ -1081,10 +1083,10 @@ def bar(self, subset=None, axis=0, color='#d65f5f', width=100,
10811083
----------
10821084
subset : IndexSlice, optional
10831085
A valid slice for `data` to limit the style application to.
1084-
axis : int, str or None, default 0
1085-
Apply to each column (`axis=0` or `'index'`)
1086-
or to each row (`axis=1` or `'columns'`) or
1087-
to the entire DataFrame at once with `axis=None`.
1086+
axis : {0 or 'index', 1 or 'columns', None}, default 0
1087+
apply to each column (``axis=0`` or ``'index'``), to each row
1088+
(``axis=1`` or ``'columns'``), or to the entire DataFrame at once
1089+
with ``axis=None``.
10881090
color : str or 2-tuple/list
10891091
If a str is passed, the color is the same for both
10901092
negative and positive numbers. If 2-tuple/list is used, the
@@ -1149,11 +1151,12 @@ def highlight_max(self, subset=None, color='yellow', axis=0):
11491151
Parameters
11501152
----------
11511153
subset : IndexSlice, default None
1152-
a valid slice for ``data`` to limit the style application to
1154+
a valid slice for ``data`` to limit the style application to.
11531155
color : str, default 'yellow'
1154-
axis : int, str, or None; default 0
1155-
0 or 'index' for columnwise (default), 1 or 'columns' for rowwise,
1156-
or ``None`` for tablewise
1156+
axis : {0 or 'index', 1 or 'columns', None}, default 0
1157+
apply to each column (``axis=0`` or ``'index'``), to each row
1158+
(``axis=1`` or ``'columns'``), or to the entire DataFrame at once
1159+
with ``axis=None``.
11571160
11581161
Returns
11591162
-------
@@ -1169,11 +1172,12 @@ def highlight_min(self, subset=None, color='yellow', axis=0):
11691172
Parameters
11701173
----------
11711174
subset : IndexSlice, default None
1172-
a valid slice for ``data`` to limit the style application to
1175+
a valid slice for ``data`` to limit the style application to.
11731176
color : str, default 'yellow'
1174-
axis : int, str, or None; default 0
1175-
0 or 'index' for columnwise (default), 1 or 'columns' for rowwise,
1176-
or ``None`` for tablewise
1177+
axis : {0 or 'index', 1 or 'columns', None}, default 0
1178+
apply to each column (``axis=0`` or ``'index'``), to each row
1179+
(``axis=1`` or ``'columns'``), or to the entire DataFrame at once
1180+
with ``axis=None``.
11771181
11781182
Returns
11791183
-------

pandas/tests/frame/test_analytics.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,7 +1385,8 @@ def test_idxmin(self, float_frame, int_frame):
13851385
skipna=skipna)
13861386
tm.assert_series_equal(result, expected)
13871387

1388-
msg = "No axis named 2 for object type <class 'type'>"
1388+
msg = ("No axis named 2 for object type"
1389+
" <class 'pandas.core.frame.DataFrame'>")
13891390
with pytest.raises(ValueError, match=msg):
13901391
frame.idxmin(axis=2)
13911392

@@ -1402,7 +1403,8 @@ def test_idxmax(self, float_frame, int_frame):
14021403
skipna=skipna)
14031404
tm.assert_series_equal(result, expected)
14041405

1405-
msg = "No axis named 2 for object type <class 'type'>"
1406+
msg = ("No axis named 2 for object type"
1407+
" <class 'pandas.core.frame.DataFrame'>")
14061408
with pytest.raises(ValueError, match=msg):
14071409
frame.idxmax(axis=2)
14081410

pandas/tests/frame/test_api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,8 @@ def test_swapaxes(self):
366366
self._assert_frame_equal(df.T, df.swapaxes(0, 1))
367367
self._assert_frame_equal(df.T, df.swapaxes(1, 0))
368368
self._assert_frame_equal(df, df.swapaxes(0, 0))
369-
msg = "No axis named 2 for object type <class 'type'>"
369+
msg = ("No axis named 2 for object type"
370+
r" <class 'pandas.core(.sparse)?.frame.(Sparse)?DataFrame'>")
370371
with pytest.raises(ValueError, match=msg):
371372
df.swapaxes(2, 5)
372373

pandas/tests/frame/test_axis_select_reindex.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,8 @@ def test_reindex_axis(self):
10671067
reindexed2 = self.intframe.reindex(index=rows)
10681068
assert_frame_equal(reindexed1, reindexed2)
10691069

1070-
msg = "No axis named 2 for object type <class 'type'>"
1070+
msg = ("No axis named 2 for object type"
1071+
" <class 'pandas.core.frame.DataFrame'>")
10711072
with pytest.raises(ValueError, match=msg):
10721073
self.intframe.reindex_axis(rows, axis=2)
10731074

pandas/tests/frame/test_missing.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ def test_dropna(self):
140140
assert_frame_equal(dropped, expected)
141141

142142
# bad input
143-
msg = "No axis named 3 for object type <class 'type'>"
143+
msg = ("No axis named 3 for object type"
144+
" <class 'pandas.core.frame.DataFrame'>")
144145
with pytest.raises(ValueError, match=msg):
145146
df.dropna(axis=3)
146147

pandas/tests/frame/test_quantile.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,12 @@ def test_quantile_axis_parameter(self):
9595
result = df.quantile(.5, axis="columns")
9696
assert_series_equal(result, expected)
9797

98-
msg = "No axis named -1 for object type <class 'type'>"
98+
msg = ("No axis named -1 for object type"
99+
" <class 'pandas.core.frame.DataFrame'>")
99100
with pytest.raises(ValueError, match=msg):
100101
df.quantile(0.1, axis=-1)
101-
msg = "No axis named column for object type <class 'type'>"
102+
msg = ("No axis named column for object type"
103+
" <class 'pandas.core.frame.DataFrame'>")
102104
with pytest.raises(ValueError, match=msg):
103105
df.quantile(0.1, axis="column")
104106

pandas/tests/frame/test_sorting.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ def test_sort_values(self):
5555
sorted_df = frame.sort_values(by=['B', 'A'], ascending=[True, False])
5656
assert_frame_equal(sorted_df, expected)
5757

58-
msg = "No axis named 2 for object type <class 'type'>"
58+
msg = ("No axis named 2 for object type"
59+
" <class 'pandas.core.frame.DataFrame'>")
5960
with pytest.raises(ValueError, match=msg):
6061
frame.sort_values(by=['A', 'B'], axis=2, inplace=True)
6162

pandas/tests/frame/test_timeseries.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,8 @@ def test_frame_to_period(self):
862862
pts = df.to_period('M', axis=1)
863863
tm.assert_index_equal(pts.columns, exp.columns.asfreq('M'))
864864

865-
msg = "No axis named 2 for object type <class 'type'>"
865+
msg = ("No axis named 2 for object type"
866+
" <class 'pandas.core.frame.DataFrame'>")
866867
with pytest.raises(ValueError, match=msg):
867868
df.to_period(axis=2)
868869

pandas/tests/series/test_analytics.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,7 @@ def test_isin_empty(self, empty):
771771
result = s.isin(empty)
772772
tm.assert_series_equal(expected, result)
773773

774+
@pytest.mark.skipif(PY2, reason="pytest.raises match regex fails")
774775
def test_ptp(self):
775776
# GH21614
776777
N = 1000
@@ -796,7 +797,8 @@ def test_ptp(self):
796797
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
797798
tm.assert_series_equal(s.ptp(level=0, skipna=False), expected)
798799

799-
msg = r"No axis named 1 for object type <(class|type) 'type'>"
800+
msg = ("No axis named 1 for object type"
801+
" <class 'pandas.core.series.Series'>")
800802
with pytest.raises(ValueError, match=msg):
801803
with tm.assert_produces_warning(FutureWarning,
802804
check_stacklevel=False):

pandas/tests/series/test_missing.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import pytz
1111

1212
from pandas._libs.tslib import iNaT
13-
from pandas.compat import range
13+
from pandas.compat import PY2, range
1414
from pandas.errors import PerformanceWarning
1515
import pandas.util._test_decorators as td
1616

@@ -654,14 +654,16 @@ def test_timedelta64_nan(self):
654654
# expected = (datetime_series >= -0.5) & (datetime_series <= 0.5)
655655
# assert_series_equal(selector, expected)
656656

657+
@pytest.mark.skipif(PY2, reason="pytest.raises match regex fails")
657658
def test_dropna_empty(self):
658659
s = Series([])
659660
assert len(s.dropna()) == 0
660661
s.dropna(inplace=True)
661662
assert len(s) == 0
662663

663664
# invalid axis
664-
msg = r"No axis named 1 for object type <(class|type) 'type'>"
665+
msg = ("No axis named 1 for object type"
666+
" <class 'pandas.core.series.Series'>")
665667
with pytest.raises(ValueError, match=msg):
666668
s.dropna(axis=1)
667669

pandas/tests/series/test_rank.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from pandas._libs.algos import Infinity, NegInfinity
1010
from pandas._libs.tslib import iNaT
1111
import pandas.compat as compat
12-
from pandas.compat import product
12+
from pandas.compat import PY2, product
1313
import pandas.util._test_decorators as td
1414

1515
from pandas import NaT, Series, Timestamp, date_range
@@ -203,10 +203,12 @@ def test_rank_categorical(self):
203203
assert_series_equal(na_ser.rank(na_option='bottom', pct=True), exp_bot)
204204
assert_series_equal(na_ser.rank(na_option='keep', pct=True), exp_keep)
205205

206+
@pytest.mark.skipif(PY2, reason="pytest.raises match regex fails")
206207
def test_rank_signature(self):
207208
s = Series([0, 1])
208209
s.rank(method='average')
209-
msg = r"No axis named average for object type <(class|type) 'type'>"
210+
msg = ("No axis named average for object type"
211+
" <class 'pandas.core.series.Series'>")
210212
with pytest.raises(ValueError, match=msg):
211213
s.rank('average')
212214

pandas/tests/series/test_sorting.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import numpy as np
66
import pytest
77

8+
from pandas.compat import PY2
9+
810
from pandas import Categorical, DataFrame, IntervalIndex, MultiIndex, Series
911
import pandas.util.testing as tm
1012
from pandas.util.testing import assert_almost_equal, assert_series_equal
@@ -88,6 +90,7 @@ def test_sort_values(self):
8890
with pytest.raises(ValueError, match=msg):
8991
s.sort_values(inplace=True)
9092

93+
@pytest.mark.skipif(PY2, reason="pytest.raises match regex fails")
9194
def test_sort_index(self):
9295
rindex = list(self.ts.index)
9396
random.shuffle(rindex)
@@ -109,7 +112,8 @@ def test_sort_index(self):
109112
sorted_series = random_order.sort_index(axis=0)
110113
assert_series_equal(sorted_series, self.ts)
111114

112-
msg = r"No axis named 1 for object type <(class|type) 'type'>"
115+
msg = ("No axis named 1 for object type"
116+
" <class 'pandas.core.series.Series'>")
113117
with pytest.raises(ValueError, match=msg):
114118
random_order.sort_values(axis=1)
115119

pandas/tests/series/test_timeseries.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from pandas._libs.tslib import iNaT
1010
from pandas._libs.tslibs.np_datetime import OutOfBoundsDatetime
11-
from pandas.compat import StringIO, lrange, product
11+
from pandas.compat import PY2, StringIO, lrange, product
1212
from pandas.errors import NullFrequencyError
1313
import pandas.util._test_decorators as td
1414

@@ -867,6 +867,7 @@ def test_between_time_formats(self):
867867
for time_string in strings:
868868
assert len(ts.between_time(*time_string)) == expected_length
869869

870+
@pytest.mark.skipif(PY2, reason="pytest.raises match regex fails")
870871
def test_between_time_axis(self):
871872
# issue 8839
872873
rng = date_range('1/1/2000', periods=100, freq='10min')
@@ -876,7 +877,8 @@ def test_between_time_axis(self):
876877

877878
assert len(ts.between_time(stime, etime)) == expected_length
878879
assert len(ts.between_time(stime, etime, axis=0)) == expected_length
879-
msg = r"No axis named 1 for object type <(class|type) 'type'>"
880+
msg = ("No axis named 1 for object type"
881+
" <class 'pandas.core.series.Series'>")
880882
with pytest.raises(ValueError, match=msg):
881883
ts.between_time(stime, etime, axis=1)
882884

setup.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,11 @@ def maybe_cythonize(extensions, *args, **kwargs):
477477
# Avoid running cythonize on `python setup.py clean`
478478
# See https://github.com/cython/cython/issues/1495
479479
return extensions
480+
if not cython:
481+
# Avoid trying to look up numpy when installing from sdist
482+
# https://github.com/pandas-dev/pandas/issues/25193
483+
# TODO: See if this can be removed after pyproject.toml added.
484+
return extensions
480485

481486
numpy_incl = pkg_resources.resource_filename('numpy', 'core/include')
482487
# TODO: Is this really necessary here?
@@ -485,11 +490,8 @@ def maybe_cythonize(extensions, *args, **kwargs):
485490
numpy_incl not in ext.include_dirs):
486491
ext.include_dirs.append(numpy_incl)
487492

488-
if cython:
489-
build_ext.render_templates(_pxifiles)
490-
return cythonize(extensions, *args, **kwargs)
491-
else:
492-
return extensions
493+
build_ext.render_templates(_pxifiles)
494+
return cythonize(extensions, *args, **kwargs)
493495

494496

495497
def srcpath(name=None, suffix='.pyx', subdir='src'):

0 commit comments

Comments
 (0)