Skip to content

Commit 0b0b072

Browse files
committed
Merge remote-tracking branch 'upstream/master' into io_csv_docstring_fixed
* upstream/master: DOC: more consistent flake8-commands in contributing.rst (pandas-dev#23724) DOC: Fixed the doctsring for _set_axis_name (GH 22895) (pandas-dev#22969) DOC: Improve GL03 message re: blank lines at end of docstrings. (pandas-dev#23649) TST: add tests for keeping dtype in Series.update (pandas-dev#23604) TST: For GH4861, Period and datetime in multiindex (pandas-dev#23776) TST: move .str-test to strings.py & parametrize it; precursor to pandas-dev#23582 (pandas-dev#23777) STY: isort tests/scalar, tests/tslibs, import libwindow instead of _window (pandas-dev#23787) BUG: fixed .str.contains(..., na=False) for categorical series (pandas-dev#22170) BUG: Maintain column order with groupby.nth (pandas-dev#22811) API/DEPR: replace kwarg "pat" with "sep" in str.[r]partition (pandas-dev#23767) CLN: Finish isort core (pandas-dev#23765) TST: Mark test_pct_max_many_rows with pytest.mark.single (pandas-dev#23799)
2 parents b19002b + df5eeec commit 0b0b072

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1083
-932
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ build: clean_pyc
1313
python setup.py build_ext --inplace
1414

1515
lint-diff:
16-
git diff master --name-only -- "*.py" | grep -E "pandas|scripts" | xargs flake8
16+
git diff upstream/master --name-only -- "*.py" | xargs flake8
1717

1818
develop: build
1919
-python setup.py develop

doc/source/contributing.rst

+9-9
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ the `flake8 <https://pypi.org/project/flake8>`_ tool
575575
and report any stylistic errors in your code. Therefore, it is helpful before
576576
submitting code to run the check yourself on the diff::
577577

578-
git diff master -u -- "*.py" | flake8 --diff
578+
git diff upstream/master -u -- "*.py" | flake8 --diff
579579

580580
This command will catch any stylistic errors in your changes specifically, but
581581
be beware it may not catch all of them. For example, if you delete the only
@@ -584,21 +584,21 @@ unused function. However, style-checking the diff will not catch this because
584584
the actual import is not part of the diff. Thus, for completeness, you should
585585
run this command, though it will take longer::
586586

587-
git diff master --name-only -- "*.py" | grep "pandas/" | xargs -r flake8
587+
git diff upstream/master --name-only -- "*.py" | xargs -r flake8
588588

589589
Note that on OSX, the ``-r`` flag is not available, so you have to omit it and
590590
run this slightly modified command::
591591

592-
git diff master --name-only -- "*.py" | grep "pandas/" | xargs flake8
592+
git diff upstream/master --name-only -- "*.py" | xargs flake8
593593

594-
Windows does not support the ``grep`` and ``xargs`` commands (unless installed
595-
for example via the `MinGW <http://www.mingw.org/>`__ toolchain), but one can
596-
imitate the behaviour as follows::
594+
Windows does not support the ``xargs`` command (unless installed for example
595+
via the `MinGW <http://www.mingw.org/>`__ toolchain), but one can imitate the
596+
behaviour as follows::
597597

598-
for /f %i in ('git diff upstream/master --name-only ^| findstr pandas/') do flake8 %i
598+
for /f %i in ('git diff upstream/master --name-only -- "*.py"') do flake8 %i
599599

600-
This will also get all the files being changed by the PR (and within the
601-
``pandas/`` folder), and run ``flake8`` on them one after the other.
600+
This will get all the files being changed by the PR (and ending with ``.py``),
601+
and run ``flake8`` on them, one after the other.
602602

603603
.. _contributing.import-formatting:
604604

doc/source/whatsnew/v0.24.0.rst

+4-1
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ Other Enhancements
288288
- Added :meth:`Interval.overlaps`, :meth:`IntervalArray.overlaps`, and :meth:`IntervalIndex.overlaps` for determining overlaps between interval-like objects (:issue:`21998`)
289289
- :func:`~DataFrame.to_parquet` now supports writing a ``DataFrame`` as a directory of parquet files partitioned by a subset of the columns when ``engine = 'pyarrow'`` (:issue:`23283`)
290290
- :meth:`Timestamp.tz_localize`, :meth:`DatetimeIndex.tz_localize`, and :meth:`Series.tz_localize` have gained the ``nonexistent`` argument for alternative handling of nonexistent times. See :ref:`timeseries.timezone_nonexistent` (:issue:`8917`)
291+
- :meth:`Index.difference` now has an optional ``sort`` parameter to specify whether the results should be sorted if possible (:issue:`17839`)
291292
- :meth:`read_excel()` now accepts ``usecols`` as a list of column names or callable (:issue:`18273`)
292293
- :meth:`MultiIndex.to_flat_index` has been added to flatten multiple levels into a single-level :class:`Index` object.
293294
- :meth:`DataFrame.to_stata` and :class:` pandas.io.stata.StataWriter117` can write mixed sting columns to Stata strl format (:issue:`23633`)
@@ -1035,6 +1036,7 @@ Deprecations
10351036
- :meth:`Timestamp.tz_localize`, :meth:`DatetimeIndex.tz_localize`, and :meth:`Series.tz_localize` have deprecated the ``errors`` argument in favor of the ``nonexistent`` argument (:issue:`8917`)
10361037
- The class ``FrozenNDArray`` has been deprecated. When unpickling, ``FrozenNDArray`` will be unpickled to ``np.ndarray`` once this class is removed (:issue:`9031`)
10371038
- The methods :meth:`DataFrame.update` and :meth:`Panel.update` have deprecated the ``raise_conflict=False|True`` keyword in favor of ``errors='ignore'|'raise'`` (:issue:`23585`)
1039+
- The methods :meth:`Series.str.partition` and :meth:`Series.str.rpartition` have deprecated the ``pat`` keyword in favor of ``sep`` (:issue:`22676`)
10381040
- Deprecated the `nthreads` keyword of :func:`pandas.read_feather` in favor of
10391041
`use_threads` to reflect the changes in pyarrow 0.11.0. (:issue:`23053`)
10401042
- :func:`pandas.read_excel` has deprecated accepting ``usecols`` as an integer. Please pass in a list of ints from 0 to ``usecols`` inclusive instead (:issue:`23527`)
@@ -1278,7 +1280,7 @@ Strings
12781280

12791281
- Bug in :meth:`Index.str.partition` was not nan-safe (:issue:`23558`).
12801282
- Bug in :meth:`Index.str.split` was not nan-safe (:issue:`23677`).
1281-
-
1283+
- Bug :func:`Series.str.contains` not respecting the ``na`` argument for a ``Categorical`` dtype ``Series`` (:issue:`22158`)
12821284

12831285
Interval
12841286
^^^^^^^^
@@ -1416,6 +1418,7 @@ Groupby/Resample/Rolling
14161418
- Bug in :meth:`DataFrame.resample` and :meth:`Series.resample` when resampling by a weekly offset (``'W'``) across a DST transition (:issue:`9119`, :issue:`21459`)
14171419
- Bug in :meth:`DataFrame.expanding` in which the ``axis`` argument was not being respected during aggregations (:issue:`23372`)
14181420
- Bug in :meth:`pandas.core.groupby.DataFrameGroupBy.transform` which caused missing values when the input function can accept a :class:`DataFrame` but renames it (:issue:`23455`).
1421+
- Bug in :func:`pandas.core.groupby.GroupBy.nth` where column order was not always preserved (:issue:`20760`)
14191422

14201423
Reshaping
14211424
^^^^^^^^^

pandas/core/arrays/base.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@
55
This is an experimental API and subject to breaking changes
66
without warning.
77
"""
8-
import numpy as np
9-
108
import operator
119

12-
from pandas.core.dtypes.generic import ABCSeries, ABCIndexClass
13-
from pandas.errors import AbstractMethodError
10+
import numpy as np
11+
12+
from pandas.compat import PY3, set_function_name
1413
from pandas.compat.numpy import function as nv
15-
from pandas.compat import set_function_name, PY3
16-
from pandas.core import ops
14+
from pandas.errors import AbstractMethodError
15+
1716
from pandas.core.dtypes.common import is_list_like
17+
from pandas.core.dtypes.generic import ABCIndexClass, ABCSeries
18+
19+
from pandas.core import ops
1820

1921
_not_implemented_message = "{} does not implement {}."
2022

pandas/core/arrays/categorical.py

+26-41
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,46 @@
11
# pylint: disable=E1101,W0232
22

3-
import numpy as np
4-
from warnings import warn
53
import textwrap
4+
from warnings import warn
65

7-
from pandas import compat
8-
from pandas.compat import u, lzip
9-
from pandas._libs import lib, algos as libalgos
6+
import numpy as np
7+
8+
from pandas._libs import algos as libalgos, lib
9+
import pandas.compat as compat
10+
from pandas.compat import lzip, u
11+
from pandas.compat.numpy import function as nv
12+
from pandas.util._decorators import (
13+
Appender, Substitution, cache_readonly, deprecate_kwarg)
14+
from pandas.util._validators import validate_bool_kwarg, validate_fillna_kwargs
1015

11-
from pandas.core.dtypes.generic import (
12-
ABCSeries, ABCIndexClass, ABCCategoricalIndex)
13-
from pandas.core.dtypes.missing import isna, notna
14-
from pandas.core.dtypes.inference import is_hashable
1516
from pandas.core.dtypes.cast import (
16-
maybe_infer_to_datetimelike,
17-
coerce_indexer_dtype)
18-
from pandas.core.dtypes.dtypes import CategoricalDtype
17+
coerce_indexer_dtype, maybe_infer_to_datetimelike)
1918
from pandas.core.dtypes.common import (
20-
ensure_int64,
21-
ensure_object,
22-
ensure_platform_int,
23-
is_extension_array_dtype,
24-
is_dtype_equal,
25-
is_datetimelike,
26-
is_datetime64_dtype,
27-
is_timedelta64_dtype,
28-
is_categorical,
29-
is_categorical_dtype,
30-
is_float_dtype,
31-
is_integer_dtype,
32-
is_object_dtype,
33-
is_list_like, is_sequence,
34-
is_scalar, is_iterator,
35-
is_dict_like)
36-
37-
from pandas.core.algorithms import factorize, take_1d, unique1d, take
19+
ensure_int64, ensure_object, ensure_platform_int, is_categorical,
20+
is_categorical_dtype, is_datetime64_dtype, is_datetimelike, is_dict_like,
21+
is_dtype_equal, is_extension_array_dtype, is_float_dtype, is_integer_dtype,
22+
is_iterator, is_list_like, is_object_dtype, is_scalar, is_sequence,
23+
is_timedelta64_dtype)
24+
from pandas.core.dtypes.dtypes import CategoricalDtype
25+
from pandas.core.dtypes.generic import (
26+
ABCCategoricalIndex, ABCIndexClass, ABCSeries)
27+
from pandas.core.dtypes.inference import is_hashable
28+
from pandas.core.dtypes.missing import isna, notna
29+
3830
from pandas.core.accessor import PandasDelegate, delegate_names
39-
from pandas.core.base import (PandasObject,
40-
NoNewAttributesMixin, _shared_docs)
31+
import pandas.core.algorithms as algorithms
32+
from pandas.core.algorithms import factorize, take, take_1d, unique1d
33+
from pandas.core.base import NoNewAttributesMixin, PandasObject, _shared_docs
4134
import pandas.core.common as com
35+
from pandas.core.config import get_option
4236
from pandas.core.missing import interpolate_2d
43-
from pandas.compat.numpy import function as nv
44-
from pandas.util._decorators import (
45-
Appender, cache_readonly, deprecate_kwarg, Substitution)
46-
47-
import pandas.core.algorithms as algorithms
48-
4937
from pandas.core.sorting import nargsort
5038

5139
from pandas.io.formats import console
5240
from pandas.io.formats.terminal import get_terminal_size
53-
from pandas.util._validators import validate_bool_kwarg, validate_fillna_kwargs
54-
from pandas.core.config import get_option
5541

5642
from .base import ExtensionArray
5743

58-
5944
_take_msg = textwrap.dedent("""\
6045
Interpreting negative values in 'indexer' as missing values.
6146
In the future, this will change to meaning positional indices

pandas/core/arrays/datetimelike.py

+15-26
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,33 @@
55

66
import numpy as np
77

8-
from pandas._libs import lib, iNaT, NaT
8+
from pandas._libs import NaT, iNaT, lib
99
from pandas._libs.tslibs import timezones
10-
from pandas._libs.tslibs.timedeltas import delta_to_nanoseconds, Timedelta
11-
from pandas._libs.tslibs.timestamps import maybe_integer_op_deprecated
1210
from pandas._libs.tslibs.period import (
13-
Period, DIFFERENT_FREQ_INDEX, IncompatibleFrequency)
14-
11+
DIFFERENT_FREQ_INDEX, IncompatibleFrequency, Period)
12+
from pandas._libs.tslibs.timedeltas import Timedelta, delta_to_nanoseconds
13+
from pandas._libs.tslibs.timestamps import maybe_integer_op_deprecated
14+
import pandas.compat as compat
1515
from pandas.errors import (
1616
AbstractMethodError, NullFrequencyError, PerformanceWarning)
17-
from pandas import compat
18-
19-
from pandas.tseries import frequencies
20-
from pandas.tseries.offsets import Tick, DateOffset
17+
from pandas.util._decorators import deprecate_kwarg
2118

2219
from pandas.core.dtypes.common import (
23-
pandas_dtype,
24-
needs_i8_conversion,
25-
is_list_like,
26-
is_offsetlike,
27-
is_extension_array_dtype,
28-
is_datetime64_dtype,
29-
is_datetime64_any_dtype,
30-
is_datetime64tz_dtype,
31-
is_float_dtype,
32-
is_integer_dtype,
33-
is_bool_dtype,
34-
is_period_dtype,
35-
is_timedelta64_dtype,
36-
is_object_dtype)
37-
from pandas.core.dtypes.generic import ABCSeries, ABCDataFrame, ABCIndexClass
20+
is_bool_dtype, is_datetime64_any_dtype, is_datetime64_dtype,
21+
is_datetime64tz_dtype, is_extension_array_dtype, is_float_dtype,
22+
is_integer_dtype, is_list_like, is_object_dtype, is_offsetlike,
23+
is_period_dtype, is_timedelta64_dtype, needs_i8_conversion, pandas_dtype)
3824
from pandas.core.dtypes.dtypes import DatetimeTZDtype
25+
from pandas.core.dtypes.generic import ABCDataFrame, ABCIndexClass, ABCSeries
3926
from pandas.core.dtypes.missing import isna
4027

41-
import pandas.core.common as com
4228
from pandas.core.algorithms import checked_add_with_arr, take, unique1d
29+
import pandas.core.common as com
30+
31+
from pandas.tseries import frequencies
32+
from pandas.tseries.offsets import DateOffset, Tick
4333

4434
from .base import ExtensionOpsMixin
45-
from pandas.util._decorators import deprecate_kwarg
4635

4736

4837
def _make_comparison_op(cls, op):

pandas/core/arrays/datetimes.py

+12-19
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,28 @@
66
from pytz import utc
77

88
from pandas._libs import lib, tslib
9-
from pandas._libs.tslib import Timestamp, NaT, iNaT
9+
from pandas._libs.tslib import NaT, Timestamp, iNaT
1010
from pandas._libs.tslibs import (
11-
ccalendar, normalize_date,
12-
conversion, fields, timezones,
13-
resolution as libresolution)
14-
15-
from pandas.util._decorators import cache_readonly, Appender
11+
ccalendar, conversion, fields, normalize_date, resolution as libresolution,
12+
timezones)
13+
import pandas.compat as compat
1614
from pandas.errors import PerformanceWarning
17-
from pandas import compat
15+
from pandas.util._decorators import Appender, cache_readonly
1816

1917
from pandas.core.dtypes.common import (
20-
_NS_DTYPE,
21-
is_object_dtype,
22-
is_int64_dtype,
23-
is_datetime64tz_dtype,
24-
is_datetime64_dtype)
18+
_NS_DTYPE, is_datetime64_dtype, is_datetime64tz_dtype, is_int64_dtype,
19+
is_object_dtype)
2520
from pandas.core.dtypes.dtypes import DatetimeTZDtype
26-
from pandas.core.dtypes.missing import isna
2721
from pandas.core.dtypes.generic import ABCIndexClass, ABCSeries
22+
from pandas.core.dtypes.missing import isna
2823

29-
import pandas.core.common as com
30-
from pandas.core.algorithms import checked_add_with_arr
3124
from pandas.core import ops
32-
33-
from pandas.tseries.frequencies import to_offset, get_period_alias
34-
from pandas.tseries.offsets import Tick, generate_range
35-
25+
from pandas.core.algorithms import checked_add_with_arr
3626
from pandas.core.arrays import datetimelike as dtl
27+
import pandas.core.common as com
3728

29+
from pandas.tseries.frequencies import get_period_alias, to_offset
30+
from pandas.tseries.offsets import Tick, generate_range
3831

3932
_midnight = time(0, 0)
4033

pandas/core/arrays/integer.py

+11-15
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,27 @@
1+
import copy
12
import sys
23
import warnings
3-
import copy
4-
import numpy as np
54

5+
import numpy as np
66

77
from pandas._libs import lib
8+
from pandas.compat import range, set_function_name, string_types, u
89
from pandas.util._decorators import cache_readonly
9-
from pandas.compat import u, range, string_types
10-
from pandas.compat import set_function_name
1110

12-
from pandas.core import nanops
11+
from pandas.core.dtypes.base import ExtensionDtype
1312
from pandas.core.dtypes.cast import astype_nansafe
14-
from pandas.core.dtypes.generic import ABCSeries, ABCIndexClass
1513
from pandas.core.dtypes.common import (
16-
is_integer, is_scalar, is_float,
17-
is_bool_dtype,
18-
is_float_dtype,
19-
is_integer_dtype,
20-
is_object_dtype,
21-
is_list_like)
22-
from pandas.core.arrays import ExtensionArray, ExtensionOpsMixin
23-
from pandas.core.dtypes.base import ExtensionDtype
14+
is_bool_dtype, is_float, is_float_dtype, is_integer, is_integer_dtype,
15+
is_list_like, is_object_dtype, is_scalar)
2416
from pandas.core.dtypes.dtypes import register_extension_dtype
17+
from pandas.core.dtypes.generic import ABCIndexClass, ABCSeries
2518
from pandas.core.dtypes.missing import isna, notna
2619

20+
from pandas.core import nanops
21+
from pandas.core.arrays import ExtensionArray, ExtensionOpsMixin
22+
2723
from pandas.io.formats.printing import (
28-
format_object_summary, format_object_attrs, default_pprint)
24+
default_pprint, format_object_attrs, format_object_summary)
2925

3026

3127
class _IntegerDtype(ExtensionDtype):

pandas/core/arrays/interval.py

+17-18
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
1+
from operator import le, lt
12
import textwrap
2-
import numpy as np
33

4-
from operator import le, lt
4+
import numpy as np
55

6-
from pandas._libs.interval import (Interval, IntervalMixin,
7-
intervals_to_interval_bounds)
6+
from pandas._libs.interval import (
7+
Interval, IntervalMixin, intervals_to_interval_bounds)
88
from pandas.compat import add_metaclass
99
from pandas.compat.numpy import function as nv
10-
import pandas.core.common as com
11-
from pandas.core.config import get_option
10+
from pandas.util._decorators import Appender
11+
from pandas.util._doctools import _WritableDoc
12+
1213
from pandas.core.dtypes.cast import maybe_convert_platform
13-
from pandas.core.dtypes.common import (is_categorical_dtype, is_float_dtype,
14-
is_integer_dtype, is_interval_dtype,
15-
is_scalar, is_string_dtype,
16-
is_datetime64_any_dtype,
17-
is_timedelta64_dtype, is_interval,
18-
pandas_dtype)
14+
from pandas.core.dtypes.common import (
15+
is_categorical_dtype, is_datetime64_any_dtype, is_float_dtype,
16+
is_integer_dtype, is_interval, is_interval_dtype, is_scalar,
17+
is_string_dtype, is_timedelta64_dtype, pandas_dtype)
1918
from pandas.core.dtypes.dtypes import IntervalDtype
20-
from pandas.core.dtypes.generic import (ABCDatetimeIndex, ABCPeriodIndex,
21-
ABCSeries, ABCIntervalIndex,
22-
ABCInterval)
19+
from pandas.core.dtypes.generic import (
20+
ABCDatetimeIndex, ABCInterval, ABCIntervalIndex, ABCPeriodIndex, ABCSeries)
2321
from pandas.core.dtypes.missing import isna, notna
22+
23+
import pandas.core.common as com
24+
from pandas.core.config import get_option
2425
from pandas.core.indexes.base import Index, ensure_index
25-
from pandas.util._decorators import Appender
26-
from pandas.util._doctools import _WritableDoc
2726

28-
from . import ExtensionArray, Categorical
27+
from . import Categorical, ExtensionArray
2928

3029
_VALID_CLOSED = {'left', 'right', 'both', 'neither'}
3130
_interval_shared_docs = {}

0 commit comments

Comments
 (0)