Skip to content

Commit 726ddaa

Browse files
committed
Merge branch 'master' of https://github.com/pandas-dev/pandas into alexdev
2 parents 06ae153 + 1779155 commit 726ddaa

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

+1026
-581
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Build pandas
2+
description: Rebuilds the C extensions and installs pandas
3+
runs:
4+
using: composite
5+
steps:
6+
7+
- name: Environment Detail
8+
run: |
9+
conda info
10+
conda list
11+
shell: bash -l {0}
12+
13+
- name: Build Pandas
14+
run: |
15+
python setup.py build_ext -j 2
16+
python -m pip install -e . --no-build-isolation --no-use-pep517
17+
shell: bash -l {0}

.github/actions/setup/action.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Set up pandas
2+
description: Runs all the setup steps required to have a built pandas ready to use
3+
runs:
4+
using: composite
5+
steps:
6+
- name: Setting conda path
7+
run: echo "${HOME}/miniconda3/bin" >> $GITHUB_PATH
8+
shell: bash -l {0}
9+
10+
- name: Setup environment and build pandas
11+
run: ci/setup_env.sh
12+
shell: bash -l {0}

.github/workflows/ci.yml

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,8 @@ jobs:
4141
environment-file: ${{ env.ENV_FILE }}
4242
use-only-tar-bz2: true
4343

44-
- name: Environment Detail
45-
run: |
46-
conda info
47-
conda list
48-
4944
- name: Build Pandas
50-
run: |
51-
python setup.py build_ext -j 2
52-
python -m pip install -e . --no-build-isolation --no-use-pep517
45+
uses: ./.github/actions/build_pandas
5346

5447
- name: Linting
5548
run: ci/code_checks.sh lint
@@ -100,14 +93,11 @@ jobs:
10093
runs-on: ubuntu-latest
10194
steps:
10295

103-
- name: Setting conda path
104-
run: echo "${HOME}/miniconda3/bin" >> $GITHUB_PATH
105-
10696
- name: Checkout
10797
uses: actions/checkout@v1
10898

109-
- name: Setup environment and build pandas
110-
run: ci/setup_env.sh
99+
- name: Set up pandas
100+
uses: ./.github/actions/setup
111101

112102
- name: Build website
113103
run: |
@@ -139,19 +129,25 @@ jobs:
139129
run: rsync -az --delete doc/build/html/ docs@${{ secrets.server_ip }}:/usr/share/nginx/pandas/pandas-docs/dev
140130
if: github.event_name == 'push'
141131

132+
- name: Move docs into site directory
133+
run: mv doc/build/html web/build/docs
134+
- name: Save website as an artifact
135+
uses: actions/upload-artifact@v2
136+
with:
137+
name: website
138+
path: web/build
139+
retention-days: 14
140+
142141
data_manager:
143142
name: Test experimental data manager
144143
runs-on: ubuntu-latest
145144
steps:
146145

147-
- name: Setting conda path
148-
run: echo "${HOME}/miniconda3/bin" >> $GITHUB_PATH
149-
150146
- name: Checkout
151147
uses: actions/checkout@v1
152148

153-
- name: Setup environment and build pandas
154-
run: ci/setup_env.sh
149+
- name: Set up pandas
150+
uses: ./.github/actions/setup
155151

156152
- name: Run tests
157153
run: |

.github/workflows/database.yml

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,8 @@ jobs:
7272
environment-file: ${{ env.ENV_FILE }}
7373
use-only-tar-bz2: true
7474

75-
- name: Environment Detail
76-
run: |
77-
conda info
78-
conda list
79-
8075
- name: Build Pandas
81-
run: |
82-
python setup.py build_ext -j 2
83-
python -m pip install -e . --no-build-isolation --no-use-pep517
76+
uses: ./.github/actions/build_pandas
8477

8578
- name: Test
8679
run: ci/run_tests.sh
@@ -158,15 +151,8 @@ jobs:
158151
environment-file: ${{ env.ENV_FILE }}
159152
use-only-tar-bz2: true
160153

161-
- name: Environment Detail
162-
run: |
163-
conda info
164-
conda list
165-
166154
- name: Build Pandas
167-
run: |
168-
python setup.py build_ext -j 2
169-
python -m pip install -e . --no-build-isolation --no-use-pep517
155+
uses: ./.github/actions/build_pandas
170156

171157
- name: Test
172158
run: ci/run_tests.sh

asv_bench/benchmarks/dtypes.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
import numpy as np
44

5+
import pandas as pd
56
from pandas import DataFrame
67
import pandas._testing as tm
7-
from pandas.api.types import pandas_dtype
8+
from pandas.api.types import is_extension_array_dtype, pandas_dtype
89

910
from .pandas_vb_common import (
1011
datetime_dtypes,
@@ -119,4 +120,16 @@ def time_select_dtype_string_exclude(self, dtype):
119120
self.df_string.select_dtypes(exclude=dtype)
120121

121122

123+
class CheckDtypes:
124+
def setup(self):
125+
self.ext_dtype = pd.Int64Dtype()
126+
self.np_dtype = np.dtype("int64")
127+
128+
def time_is_extension_array_dtype_true(self):
129+
is_extension_array_dtype(self.ext_dtype)
130+
131+
def time_is_extension_array_dtype_false(self):
132+
is_extension_array_dtype(self.np_dtype)
133+
134+
122135
from .pandas_vb_common import setup # noqa: F401 isort:skip

asv_bench/benchmarks/gil.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import numpy as np
22

33
from pandas import DataFrame, Series, date_range, factorize, read_csv
4-
from pandas.core.algorithms import take_1d
4+
from pandas.core.algorithms import take_nd
55

66
from .pandas_vb_common import tm
77

@@ -110,7 +110,7 @@ def setup(self, dtype):
110110

111111
@test_parallel(num_threads=2)
112112
def parallel_take1d():
113-
take_1d(df["col"].values, indexer)
113+
take_nd(df["col"].values, indexer)
114114

115115
self.parallel_take1d = parallel_take1d
116116

doc/cheatsheet/Pandas_Cheat_Sheet.pdf

39.9 KB
Binary file not shown.
2.18 KB
Binary file not shown.

doc/source/development/contributing.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,17 @@ the documentation are also built by Travis-CI. These docs are then hosted `here
629629
<https://pandas.pydata.org/docs/dev/>`__, see also
630630
the :ref:`Continuous Integration <contributing.ci>` section.
631631

632+
Previewing changes
633+
------------------
634+
635+
Once, the pull request is submitted, GitHub Actions will automatically build the
636+
documentation. To view the built site:
637+
638+
#. Wait for the ``CI / Web and docs`` check to complete.
639+
#. Click ``Details`` next to it.
640+
#. From the ``Artifacts`` drop-down, click ``docs`` or ``website`` to download
641+
the site as a ZIP file.
642+
632643
.. _contributing.code:
633644

634645
Contributing to the code base

doc/source/user_guide/options.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace:
3131
* :func:`~pandas.option_context` - execute a codeblock with a set of options
3232
that revert to prior settings after execution.
3333

34-
**Note:** Developers can check out `pandas/core/config.py <https://github.com/pandas-dev/pandas/blob/master/pandas/core/config.py>`_ for more information.
34+
**Note:** Developers can check out `pandas/core/config_init.py <https://github.com/pandas-dev/pandas/blob/master/pandas/core/config_init.py>`_ for more information.
3535

3636
All of the functions above accept a regexp pattern (``re.search`` style) as an argument,
3737
and so passing in a substring will work - as long as it is unambiguous:

doc/source/whatsnew/v1.3.0.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Other enhancements
5858
- :meth:`.Styler.apply` now more consistently accepts ndarray function returns, i.e. in all cases for ``axis`` is ``0, 1 or None``. (:issue:`39359`)
5959
- :meth:`Series.loc.__getitem__` and :meth:`Series.loc.__setitem__` with :class:`MultiIndex` now raising helpful error message when indexer has too many dimensions (:issue:`35349`)
6060
- :meth:`pandas.read_stata` and :class:`StataReader` support reading data from compressed files.
61-
61+
- Add support for parsing ``ISO 8601``-like timestamps with negative signs to :meth:`pandas.Timedelta` (:issue:`37172`)
6262

6363
.. ---------------------------------------------------------------------------
6464
@@ -292,7 +292,7 @@ Timedelta
292292
^^^^^^^^^
293293
- Bug in constructing :class:`Timedelta` from ``np.timedelta64`` objects with non-nanosecond units that are out of bounds for ``timedelta64[ns]`` (:issue:`38965`)
294294
- Bug in constructing a :class:`TimedeltaIndex` incorrectly accepting ``np.datetime64("NaT")`` objects (:issue:`39462`)
295-
-
295+
- Bug in constructing :class:`Timedelta` from input string with only symbols and no digits failed to raise an error (:issue:`39710`)
296296

297297
Timezones
298298
^^^^^^^^^
@@ -335,6 +335,7 @@ Indexing
335335
- Bug in :meth:`DataFrame.__setitem__` raising ``ValueError`` when setting multiple values to duplicate columns (:issue:`15695`)
336336
- Bug in :meth:`DataFrame.loc`, :meth:`Series.loc`, :meth:`DataFrame.__getitem__` and :meth:`Series.__getitem__` returning incorrect elements for non-monotonic :class:`DatetimeIndex` for string slices (:issue:`33146`)
337337
- Bug in :meth:`DataFrame.reindex` and :meth:`Series.reindex` with timezone aware indexes raising ``TypeError`` for ``method="ffill"`` and ``method="bfill"`` and specified ``tolerance`` (:issue:`38566`)
338+
- Bug in :meth:`DataFrame.reindex` with ``datetime64[ns]`` or ``timedelta64[ns]`` incorrectly casting to integers when the ``fill_value`` requires casting to object dtype (:issue:`39755`)
338339
- Bug in :meth:`DataFrame.__setitem__` raising ``ValueError`` with empty :class:`DataFrame` and specified columns for string indexer and non empty :class:`DataFrame` to set (:issue:`38831`)
339340
- Bug in :meth:`DataFrame.loc.__setitem__` raising ValueError when expanding unique column for :class:`DataFrame` with duplicate columns (:issue:`38521`)
340341
- Bug in :meth:`DataFrame.iloc.__setitem__` and :meth:`DataFrame.loc.__setitem__` with mixed dtypes when setting with a dictionary value (:issue:`38335`)
@@ -450,11 +451,13 @@ Other
450451
- Bug in constructing a :class:`Series` from a list and a :class:`PandasDtype` (:issue:`39357`)
451452
- Bug in :class:`Styler` which caused CSS to duplicate on multiple renders. (:issue:`39395`)
452453
- ``inspect.getmembers(Series)`` no longer raises an ``AbstractMethodError`` (:issue:`38782`)
454+
- Bug in :meth:`Series.where` with numeric dtype and ``other = None`` not casting to ``nan`` (:issue:`39761`)
453455
- :meth:`Index.where` behavior now mirrors :meth:`Index.putmask` behavior, i.e. ``index.where(mask, other)`` matches ``index.putmask(~mask, other)`` (:issue:`39412`)
454456
- Bug in :func:`pandas.testing.assert_series_equal`, :func:`pandas.testing.assert_frame_equal`, :func:`pandas.testing.assert_index_equal` and :func:`pandas.testing.assert_extension_array_equal` incorrectly raising when an attribute has an unrecognized NA type (:issue:`39461`)
455457
- Bug in :class:`Styler` where ``subset`` arg in methods raised an error for some valid multiindex slices (:issue:`33562`)
456458
- :class:`Styler` rendered HTML output minor alterations to support w3 good code standard (:issue:`39626`)
457-
-
459+
- Bug in :meth:`DataFrame.equals`, :meth:`Series.equals`, :meth:`Index.equals` with object-dtype containing ``np.datetime64("NaT")`` or ``np.timedelta64("NaT")`` (:issue:`39650`)
460+
458461

459462
.. ---------------------------------------------------------------------------
460463

pandas/_config/display.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44

55
import locale
66
import sys
7+
from typing import Optional
78

89
from pandas._config import config as cf
910

1011
# -----------------------------------------------------------------------------
1112
# Global formatting options
12-
_initial_defencoding = None
13+
_initial_defencoding: Optional[str] = None
1314

1415

1516
def detect_console_encoding() -> str:

pandas/_libs/lib.pyx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ from pandas._libs.tslib import array_to_datetime
7373
from pandas._libs.missing cimport (
7474
C_NA,
7575
checknull,
76+
is_matching_na,
7677
is_null_datetime64,
7778
is_null_timedelta64,
7879
isnaobj,
@@ -584,8 +585,10 @@ def array_equivalent_object(left: object[:], right: object[:]) -> bool:
584585
return False
585586
elif (x is C_NA) ^ (y is C_NA):
586587
return False
587-
elif not (PyObject_RichCompareBool(x, y, Py_EQ) or
588-
(x is None or is_nan(x)) and (y is None or is_nan(y))):
588+
elif not (
589+
PyObject_RichCompareBool(x, y, Py_EQ)
590+
or is_matching_na(x, y, nan_matches_none=True)
591+
):
589592
return False
590593
except ValueError:
591594
# Avoid raising ValueError when comparing Numpy arrays to other types

pandas/_libs/missing.pxd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from numpy cimport ndarray, uint8_t
22

33

4+
cpdef bint is_matching_na(object left, object right, bint nan_matches_none=*)
5+
46
cpdef bint checknull(object val)
57
cpdef bint checknull_old(object val)
68
cpdef ndarray[uint8_t] isnaobj(ndarray arr)

pandas/_libs/missing.pyx

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,58 @@ cdef:
2929
bint is_32bit = not IS64
3030

3131

32+
cpdef bint is_matching_na(object left, object right, bint nan_matches_none=False):
33+
"""
34+
Check if two scalars are both NA of matching types.
35+
36+
Parameters
37+
----------
38+
left : Any
39+
right : Any
40+
nan_matches_none : bool, default False
41+
For backwards compatibility, consider NaN as matching None.
42+
43+
Returns
44+
-------
45+
bool
46+
"""
47+
if left is None:
48+
if nan_matches_none and util.is_nan(right):
49+
return True
50+
return right is None
51+
elif left is C_NA:
52+
return right is C_NA
53+
elif left is NaT:
54+
return right is NaT
55+
elif util.is_float_object(left):
56+
if nan_matches_none and right is None:
57+
return True
58+
return (
59+
util.is_nan(left)
60+
and util.is_float_object(right)
61+
and util.is_nan(right)
62+
)
63+
elif util.is_complex_object(left):
64+
return (
65+
util.is_nan(left)
66+
and util.is_complex_object(right)
67+
and util.is_nan(right)
68+
)
69+
elif util.is_datetime64_object(left):
70+
return (
71+
get_datetime64_value(left) == NPY_NAT
72+
and util.is_datetime64_object(right)
73+
and get_datetime64_value(right) == NPY_NAT
74+
)
75+
elif util.is_timedelta64_object(left):
76+
return (
77+
get_timedelta64_value(left) == NPY_NAT
78+
and util.is_timedelta64_object(right)
79+
and get_timedelta64_value(right) == NPY_NAT
80+
)
81+
return False
82+
83+
3284
cpdef bint checknull(object val):
3385
"""
3486
Return boolean describing of the input is NA-like, defined here as any

0 commit comments

Comments
 (0)