Skip to content

Commit ac64bb0

Browse files
committed
Merge branch 'master' of https://github.com/pandas-dev/pandas into cln-idx
2 parents b2f195b + 7c94949 commit ac64bb0

Some content is hidden

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

48 files changed

+570
-375
lines changed

.devcontainer.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or the definition README at
2+
// https://github.com/microsoft/vscode-dev-containers/tree/master/containers/python-3-miniconda
3+
{
4+
"name": "pandas",
5+
"context": ".",
6+
"dockerFile": "Dockerfile",
7+
8+
// Use 'settings' to set *default* container specific settings.json values on container create.
9+
// You can edit these settings after create using File > Preferences > Settings > Remote.
10+
"settings": {
11+
"terminal.integrated.shell.linux": "/bin/bash",
12+
"python.condaPath": "/opt/conda/bin/conda",
13+
"python.pythonPath": "/opt/conda/bin/python",
14+
"python.formatting.provider": "black",
15+
"python.linting.enabled": true,
16+
"python.linting.flake8Enabled": true,
17+
"python.linting.pylintEnabled": false,
18+
"python.linting.mypyEnabled": true,
19+
"python.testing.pytestEnabled": true,
20+
"python.testing.cwd": "pandas/tests"
21+
},
22+
23+
// Add the IDs of extensions you want installed when the container is created in the array below.
24+
"extensions": [
25+
"ms-python.python",
26+
"ms-vscode.cpptools"
27+
]
28+
}

.travis.yml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ python: 3.7
77
# travis cache --delete inside the project directory from the travis command line client
88
# The cache directories will be deleted if anything in ci/ changes in a commit
99
cache:
10-
ccache: true
11-
directories:
12-
- $HOME/.cache # cython cache
13-
- $HOME/.ccache # compiler cache
10+
ccache: true
11+
directories:
12+
- $HOME/.cache # cython cache
13+
- $HOME/.ccache # compiler cache
1414

1515
env:
1616
global:
@@ -20,13 +20,13 @@ env:
2020
- secure: "EkWLZhbrp/mXJOx38CHjs7BnjXafsqHtwxPQrqWy457VDFWhIY1DMnIR/lOWG+a20Qv52sCsFtiZEmMfUjf0pLGXOqurdxbYBGJ7/ikFLk9yV2rDwiArUlVM9bWFnFxHvdz9zewBH55WurrY4ShZWyV+x2dWjjceWG5VpWeI6sA="
2121

2222
git:
23-
# for cloning
24-
depth: false
23+
# for cloning
24+
depth: false
2525

2626
matrix:
27-
fast_finish: true
27+
fast_finish: true
2828

29-
include:
29+
include:
3030
- env:
3131
- JOB="3.8" ENV_FILE="ci/deps/travis-38.yaml" PATTERN="(not slow and not network and not clipboard)"
3232

@@ -40,6 +40,9 @@ matrix:
4040
- postgresql
4141

4242
- env:
43+
# Enabling Deprecations when running tests
44+
# PANDAS_TESTING_MODE="deprecate" causes DeprecationWarning messages to be displayed in the logs
45+
# See pandas/_testing.py for more details.
4346
- JOB="3.6, coverage" ENV_FILE="ci/deps/travis-36-cov.yaml" PATTERN="((not slow and not network and not clipboard) or (single and db))" PANDAS_TESTING_MODE="deprecate" COVERAGE=true SQL="1"
4447
services:
4548
- mysql
@@ -70,7 +73,6 @@ before_install:
7073
# This overrides travis and tells it to look nowhere.
7174
- export BOTO_CONFIG=/dev/null
7275

73-
7476
install:
7577
- echo "install start"
7678
- ci/prep_cython_cache.sh
@@ -87,5 +89,5 @@ script:
8789
after_script:
8890
- echo "after_script start"
8991
- source activate pandas-dev && pushd /tmp && python -c "import pandas; pandas.show_versions();" && popd
90-
- ci/print_skipped.py
92+
- ci/print_skipped.py
9193
- echo "after_script done"

Dockerfile

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
FROM continuumio/miniconda3
2+
3+
# if you forked pandas, you can pass in your own GitHub username to use your fork
4+
# i.e. gh_username=myname
5+
ARG gh_username=pandas-dev
6+
ARG pandas_home="/home/pandas"
7+
8+
# Avoid warnings by switching to noninteractive
9+
ENV DEBIAN_FRONTEND=noninteractive
10+
11+
# Configure apt and install packages
12+
RUN apt-get update \
13+
&& apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \
14+
#
15+
# Verify git, process tools, lsb-release (common in install instructions for CLIs) installed
16+
&& apt-get -y install git iproute2 procps iproute2 lsb-release \
17+
#
18+
# Install C compilers (gcc not enough, so just went with build-essential which admittedly might be overkill),
19+
# needed to build pandas C extensions
20+
&& apt-get -y install build-essential \
21+
#
22+
# cleanup
23+
&& apt-get autoremove -y \
24+
&& apt-get clean -y \
25+
&& rm -rf /var/lib/apt/lists/*
26+
27+
# Switch back to dialog for any ad-hoc use of apt-get
28+
ENV DEBIAN_FRONTEND=dialog
29+
30+
# Clone pandas repo
31+
RUN mkdir "$pandas_home" \
32+
&& git clone "https://github.com/$gh_username/pandas.git" "$pandas_home" \
33+
&& cd "$pandas_home" \
34+
&& git remote add upstream "https://github.com/pandas-dev/pandas.git" \
35+
&& git pull upstream master
36+
37+
# Because it is surprisingly difficult to activate a conda environment inside a DockerFile
38+
# (from personal experience and per https://github.com/ContinuumIO/docker-images/issues/89),
39+
# we just update the base/root one from the 'environment.yml' file instead of creating a new one.
40+
#
41+
# Set up environment
42+
RUN conda env update -n base -f "$pandas_home/environment.yml"
43+
44+
# Build C extensions and pandas
45+
RUN cd "$pandas_home" \
46+
&& python setup.py build_ext --inplace -j 4 \
47+
&& python -m pip install -e .

LICENSE

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
BSD 3-Clause License
22

3-
Copyright (c) 2008-2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
3+
Copyright (c) 2008-2011, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
44
All rights reserved.
55

6+
Copyright (c) 2011-2020, Open source contributors.
7+
68
Redistribution and use in source and binary forms, with or without
79
modification, are permitted provided that the following conditions are met:
810

doc/source/development/contributing.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,17 @@ requires a C compiler and Python environment. If you're making documentation
146146
changes, you can skip to :ref:`contributing.documentation` but you won't be able
147147
to build the documentation locally before pushing your changes.
148148

149+
Using a Docker Container
150+
~~~~~~~~~~~~~~~~~~~~~~~~
151+
152+
Instead of manually setting up a development environment, you can use Docker to
153+
automatically create the environment with just several commands. Pandas provides a `DockerFile`
154+
in the root directory to build a Docker image with a full pandas development environment.
155+
156+
Even easier, you can use the DockerFile to launch a remote session with Visual Studio Code,
157+
a popular free IDE, using the `.devcontainer.json` file.
158+
See https://code.visualstudio.com/docs/remote/containers for details.
159+
149160
.. _contributing.dev_c:
150161

151162
Installing a C compiler
@@ -1525,3 +1536,19 @@ The branch will still exist on GitHub, so to delete it there do::
15251536
git push origin --delete shiny-new-feature
15261537

15271538
.. _Gitter: https://gitter.im/pydata/pandas
1539+
1540+
1541+
Tips for a successful Pull Request
1542+
==================================
1543+
1544+
If you have made it to the `Review your code`_ phase, one of the core contributors may
1545+
take a look. Please note however that a handful of people are responsible for reviewing
1546+
all of the contributions, which can often lead to bottlenecks.
1547+
1548+
To improve the chances of your pull request being reviewed, you should:
1549+
1550+
- **Reference an open issue** for non-trivial changes to clarify the PR's purpose
1551+
- **Ensure you have appropriate tests**. These should be the first part of any PR
1552+
- **Keep your pull requests as simple as possible**. Larger PRs take longer to review
1553+
- **Ensure that CI is in a green state**. Reviewers may not even look otherwise
1554+
- **Keep** `Updating your pull request`_, either by request or every few days

doc/source/ecosystem.rst

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,14 @@ also goes beyond matplotlib and pandas with the option to perform statistical
122122
estimation while plotting, aggregating across observations and visualizing the
123123
fit of statistical models to emphasize patterns in a dataset.
124124

125-
`yhat/ggpy <https://github.com/yhat/ggpy>`__
126-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
125+
`plotnine <https://github.com/has2k1/plotnine/>`__
126+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
127127

128128
Hadley Wickham's `ggplot2 <https://ggplot2.tidyverse.org/>`__ is a foundational exploratory visualization package for the R language.
129129
Based on `"The Grammar of Graphics" <https://www.cs.uic.edu/~wilkinson/TheGrammarOfGraphics/GOG.html>`__ it
130130
provides a powerful, declarative and extremely general way to generate bespoke plots of any kind of data.
131-
It's really quite incredible. Various implementations to other languages are available,
132-
but a faithful implementation for Python users has long been missing. Although still young
133-
(as of Jan-2014), the `yhat/ggpy <https://github.com/yhat/ggpy>`__ project has been
134-
progressing quickly in that direction.
131+
Various implementations to other languages are available.
132+
A good implementation for Python users is `has2k1/plotnine <https://github.com/has2k1/plotnine/>`__.
135133

136134
`IPython Vega <https://github.com/vega/ipyvega>`__
137135
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

doc/source/whatsnew/v1.0.0.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,25 @@ Use :meth:`arrays.IntegerArray.to_numpy` with an explicit ``na_value`` instead.
483483
484484
a.to_numpy(dtype="float", na_value=np.nan)
485485
486+
**Reductions can return ``pd.NA``**
487+
488+
When performing a reduction such as a sum with ``skipna=False``, the result
489+
will now be ``pd.NA`` instead of ``np.nan`` in presence of missing values
490+
(:issue:`30958`).
491+
492+
*pandas 0.25.x*
493+
494+
.. code-block:: python
495+
496+
>>> pd.Series(a).sum(skipna=False)
497+
nan
498+
499+
*pandas 1.0.0*
500+
501+
.. ipython:: python
502+
503+
pd.Series(a).sum(skipna=False)
504+
486505
**value_counts returns a nullable integer dtype**
487506

488507
:meth:`Series.value_counts` with a nullable integer dtype now returns a nullable

doc/source/whatsnew/v1.1.0.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Categorical
6060
Datetimelike
6161
^^^^^^^^^^^^
6262
- Bug in :class:`Timestamp` where constructing :class:`Timestamp` from ambiguous epoch time and calling constructor again changed :meth:`Timestamp.value` property (:issue:`24329`)
63-
-
63+
- :meth:`DatetimeArray.searchsorted`, :meth:`TimedeltaArray.searchsorted`, :meth:`PeriodArray.searchsorted` not recognizing non-pandas scalars and incorrectly raising ``ValueError`` instead of ``TypeError`` (:issue:`30950`)
6464
-
6565

6666
Timedelta
@@ -102,7 +102,7 @@ Interval
102102

103103
Indexing
104104
^^^^^^^^
105-
105+
- Bug in slicing on a :class:`DatetimeIndex` with a partial-timestamp dropping high-resolution indices near the end of a year, quarter, or month (:issue:`31064`)
106106
-
107107
-
108108

@@ -142,6 +142,9 @@ Reshaping
142142

143143
-
144144
- Bug in :meth:`DataFrame.pivot_table` when only MultiIndexed columns is set (:issue:`17038`)
145+
- Fix incorrect error message in :meth:`DataFrame.pivot` when ``columns`` is set to ``None``. (:issue:`30924`)
146+
- Bug in :func:`crosstab` when inputs are two Series and have tuple names, the output will keep dummy MultiIndex as columns. (:issue:`18321`)
147+
145148

146149
Sparse
147150
^^^^^^

pandas/_libs/index.pyx

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ cdef class IndexEngine:
213213
return self.monotonic_dec == 1
214214

215215
cdef inline _do_monotonic_check(self):
216-
cdef object is_unique
216+
cdef:
217+
bint is_unique
217218
try:
218219
values = self._get_index_values()
219220
self.monotonic_inc, self.monotonic_dec, is_unique = \
@@ -236,10 +237,10 @@ cdef class IndexEngine:
236237
cdef _call_monotonic(self, values):
237238
return algos.is_monotonic(values, timelike=False)
238239

239-
def get_backfill_indexer(self, other, limit=None):
240+
def get_backfill_indexer(self, other: np.ndarray, limit=None) -> np.ndarray:
240241
return algos.backfill(self._get_index_values(), other, limit=limit)
241242

242-
def get_pad_indexer(self, other, limit=None):
243+
def get_pad_indexer(self, other: np.ndarray, limit=None) -> np.ndarray:
243244
return algos.pad(self._get_index_values(), other, limit=limit)
244245

245246
cdef _make_hash_table(self, Py_ssize_t n):
@@ -477,13 +478,13 @@ cdef class DatetimeEngine(Int64Engine):
477478
values = np.asarray(values).view('i8')
478479
return self.mapping.lookup(values)
479480

480-
def get_pad_indexer(self, other, limit=None):
481+
def get_pad_indexer(self, other: np.ndarray, limit=None) -> np.ndarray:
481482
if other.dtype != self._get_box_dtype():
482483
return np.repeat(-1, len(other)).astype('i4')
483484
other = np.asarray(other).view('i8')
484485
return algos.pad(self._get_index_values(), other, limit=limit)
485486

486-
def get_backfill_indexer(self, other, limit=None):
487+
def get_backfill_indexer(self, other: np.ndarray, limit=None) -> np.ndarray:
487488
if other.dtype != self._get_box_dtype():
488489
return np.repeat(-1, len(other)).astype('i4')
489490
other = np.asarray(other).view('i8')
@@ -506,16 +507,13 @@ cdef class PeriodEngine(Int64Engine):
506507
cdef _get_index_values(self):
507508
return super(PeriodEngine, self).vgetter().view("i8")
508509

509-
cdef void _call_map_locations(self, values):
510-
# super(...) pattern doesn't seem to work with `cdef`
511-
Int64Engine._call_map_locations(self, values.view('i8'))
512-
513510
cdef _call_monotonic(self, values):
514511
# super(...) pattern doesn't seem to work with `cdef`
515512
return Int64Engine._call_monotonic(self, values.view('i8'))
516513

517514
def get_indexer(self, values):
518-
cdef ndarray[int64_t, ndim=1] ordinals
515+
cdef:
516+
ndarray[int64_t, ndim=1] ordinals
519517

520518
super(PeriodEngine, self)._ensure_mapping_populated()
521519

@@ -524,14 +522,14 @@ cdef class PeriodEngine(Int64Engine):
524522

525523
return self.mapping.lookup(ordinals)
526524

527-
def get_pad_indexer(self, other, limit=None):
525+
def get_pad_indexer(self, other: np.ndarray, limit=None) -> np.ndarray:
528526
freq = super(PeriodEngine, self).vgetter().freq
529527
ordinal = periodlib.extract_ordinals(other, freq)
530528

531529
return algos.pad(self._get_index_values(),
532530
np.asarray(ordinal), limit=limit)
533531

534-
def get_backfill_indexer(self, other, limit=None):
532+
def get_backfill_indexer(self, other: np.ndarray, limit=None) -> np.ndarray:
535533
freq = super(PeriodEngine, self).vgetter().freq
536534
ordinal = periodlib.extract_ordinals(other, freq)
537535

pandas/_libs/index_class_helper.pxi.in

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,7 @@ cdef class {{name}}Engine(IndexEngine):
5353
ndarray[{{ctype}}] values
5454
int count = 0
5555

56-
{{if name not in {'Float64', 'Float32'} }}
57-
if not util.is_integer_object(val):
58-
raise KeyError(val)
59-
{{endif}}
56+
self._check_type(val)
6057

6158
# A view is needed for some subclasses, such as PeriodEngine:
6259
values = self._get_index_values().view('{{dtype}}')

0 commit comments

Comments
 (0)