Skip to content

Commit 41e6ce4

Browse files
committed
Merge remote-tracking branch 'upstream/master' into bug/categorical-indexing-1row-df
* upstream/master: (194 commits) DOC Remove Python 2 specific comments from documentation (pandas-dev#31198) Follow up PR: pandas-dev#28097 Simplify branch statement (pandas-dev#29243) BUG: DatetimeIndex.snap incorrectly setting freq (pandas-dev#31188) Move DataFrame.info() to live with similar functions (pandas-dev#31317) ENH: accept a dictionary in plot colors (pandas-dev#31071) PERF: add shortcut to Timestamp constructor (pandas-dev#30676) CLN/MAINT: Clean and annotate stata reader and writers (pandas-dev#31072) REF: define _get_slice_axis in correct classes (pandas-dev#31304) BUG: DataFrame.floordiv(ser, axis=0) not matching column-wise bheavior (pandas-dev#31271) PERF: optimize is_scalar, is_iterator (pandas-dev#31294) BUG: Series rolling count ignores min_periods (pandas-dev#30923) xfail sparse warning; closes pandas-dev#31310 (pandas-dev#31311) REF: DatetimeIndex.get_value wrap DTI.get_loc (pandas-dev#31314) CLN: internals.managers (pandas-dev#31316) PERF: avoid copies if possible in fill_binop (pandas-dev#31300) Add test for multiindex json (pandas-dev#31307) BUG: passing TDA and wrong freq to TimedeltaIndex (pandas-dev#31268) BUG: inconsistency between PeriodIndex.get_value vs get_loc (pandas-dev#31172) CLN: remove _set_subtyp (pandas-dev#31301) CI: Updated version of macos image (pandas-dev#31292) ...
2 parents 241bd7c + ca3bfcc commit 41e6ce4

File tree

403 files changed

+8078
-12046
lines changed

Some content is hidden

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

403 files changed

+8078
-12046
lines changed

.devcontainer.json

+28
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+
}

.github/CODE_OF_CONDUCT.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ incident.
5454

5555
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
5656
version 1.3.0, available at
57-
[http://contributor-covenant.org/version/1/3/0/][version],
57+
[https://www.contributor-covenant.org/version/1/3/0/][version],
5858
and the [Swift Code of Conduct][swift].
5959

60-
[homepage]: http://contributor-covenant.org
61-
[version]: http://contributor-covenant.org/version/1/3/0/
60+
[homepage]: https://www.contributor-covenant.org
61+
[version]: https://www.contributor-covenant.org/version/1/3/0/
6262
[swift]: https://swift.org/community/#code-of-conduct
6363

.github/CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ If you notice a bug in the code or documentation, or have suggestions for how we
1616

1717
## Contributing to the Codebase
1818

19-
The code is hosted on [GitHub](https://www.github.com/pandas-dev/pandas), so you will need to use [Git](http://git-scm.com/) to clone the project and make changes to the codebase. Once you have obtained a copy of the code, you should create a development environment that is separate from your existing Python environment so that you can make and test changes without compromising your own work environment. For more information, please refer to the "[Working with the code](https://github.com/pandas-dev/pandas/blob/master/doc/source/development/contributing.rst#working-with-the-code)" section.
19+
The code is hosted on [GitHub](https://www.github.com/pandas-dev/pandas), so you will need to use [Git](https://git-scm.com/) to clone the project and make changes to the codebase. Once you have obtained a copy of the code, you should create a development environment that is separate from your existing Python environment so that you can make and test changes without compromising your own work environment. For more information, please refer to the "[Working with the code](https://github.com/pandas-dev/pandas/blob/master/doc/source/development/contributing.rst#working-with-the-code)" section.
2020

2121
Before submitting your changes for review, make sure to check that your changes do not break any tests. You can find more information about our test suites in the "[Test-driven development/code writing](https://github.com/pandas-dev/pandas/blob/master/doc/source/development/contributing.rst#test-driven-development-code-writing)" section. We also have guidelines regarding coding style that will be enforced during testing, which can be found in the "[Code standards](https://github.com/pandas-dev/pandas/blob/master/doc/source/development/contributing.rst#code-standards)" section.
2222

.github/workflows/assign.yml

+5-6
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ jobs:
77
one:
88
runs-on: ubuntu-latest
99
steps:
10-
- name:
11-
run: |
12-
if [[ "${{ github.event.comment.body }}" == "take" ]]; then
13-
echo "Assigning issue ${{ github.event.issue.number }} to ${{ github.event.comment.user.login }}"
14-
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -d '{"assignees": ["${{ github.event.comment.user.login }}"]}' https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/assignees
15-
fi
10+
- if: github.event.comment.body == 'take'
11+
name:
12+
run: |
13+
echo "Assigning issue ${{ github.event.issue.number }} to ${{ github.event.comment.user.login }}"
14+
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -d '{"assignees": ["${{ github.event.comment.user.login }}"]}' https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/assignees

.pre-commit-config.yaml

+7-7
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ repos:
2020
rev: v0.730
2121
hooks:
2222
- id: mypy
23-
# We run mypy over all files because of:
24-
# * changes in type definitions may affect non-touched files.
25-
# * Running it with `mypy pandas` and the filenames will lead to
26-
# spurious duplicate module errors,
27-
# see also https://github.com/pre-commit/mirrors-mypy/issues/5
28-
pass_filenames: false
2923
args:
30-
- pandas
24+
# As long as a some files are excluded from check-untyped-defs
25+
# we have to exclude it from the pre-commit hook as the configuration
26+
# is based on modules but the hook runs on files.
27+
- --no-check-untyped-defs
28+
- --follow-imports
29+
- skip
30+
files: pandas/

.travis.yml

+16-17
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,30 +20,30 @@ 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
28-
exclude:
29-
# Exclude the default Python 3.5 build
30-
- python: 3.5
27+
fast_finish: true
3128

32-
include:
29+
include:
3330
- env:
34-
- JOB="3.8" ENV_FILE="ci/deps/travis-38.yaml" PATTERN="(not slow and not network)"
31+
- JOB="3.8" ENV_FILE="ci/deps/travis-38.yaml" PATTERN="(not slow and not network and not clipboard)"
3532

3633
- env:
37-
- JOB="3.7" ENV_FILE="ci/deps/travis-37.yaml" PATTERN="(not slow and not network)"
34+
- JOB="3.7" ENV_FILE="ci/deps/travis-37.yaml" PATTERN="(not slow and not network and not clipboard)"
3835

3936
- env:
40-
- JOB="3.6, locale" ENV_FILE="ci/deps/travis-36-locale.yaml" PATTERN="((not slow and not network) or (single and db))" LOCALE_OVERRIDE="zh_CN.UTF-8" SQL="1"
37+
- JOB="3.6, locale" ENV_FILE="ci/deps/travis-36-locale.yaml" PATTERN="((not slow and not network and not clipboard) or (single and db))" LOCALE_OVERRIDE="zh_CN.UTF-8" SQL="1"
4138
services:
4239
- mysql
4340
- postgresql
4441

4542
- env:
46-
- JOB="3.6, coverage" ENV_FILE="ci/deps/travis-36-cov.yaml" PATTERN="((not slow and not network) or (single and db))" PANDAS_TESTING_MODE="deprecate" COVERAGE=true SQL="1"
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.
46+
- 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"
4747
services:
4848
- mysql
4949
- postgresql
@@ -73,7 +73,6 @@ before_install:
7373
# This overrides travis and tells it to look nowhere.
7474
- export BOTO_CONFIG=/dev/null
7575

76-
7776
install:
7877
- echo "install start"
7978
- ci/prep_cython_cache.sh
@@ -90,5 +89,5 @@ script:
9089
after_script:
9190
- echo "after_script start"
9291
- source activate pandas-dev && pushd /tmp && python -c "import pandas; pandas.show_versions();" && popd
93-
- ci/print_skipped.py
92+
- ci/print_skipped.py
9493
- echo "after_script done"

AUTHORS.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ About the Copyright Holders
1414
The PyData Development Team is the collection of developers of the PyData
1515
project. This includes all of the PyData sub-projects, including pandas. The
1616
core team that coordinates development on GitHub can be found here:
17-
http://github.com/pydata.
17+
https://github.com/pydata.
1818

1919
Full credits for pandas contributors can be found in the documentation.
2020

Dockerfile

+47
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

+3-1
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

RELEASE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ Release Notes
33

44
The list of changes to Pandas between each release can be found
55
[here](https://pandas.pydata.org/pandas-docs/stable/whatsnew/index.html). For full
6-
details, see the commit logs at http://github.com/pandas-dev/pandas.
6+
details, see the commit logs at https://github.com/pandas-dev/pandas.

asv_bench/asv.conf.json

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"matplotlib": [],
4444
"sqlalchemy": [],
4545
"scipy": [],
46+
"numba": [],
4647
"numexpr": [],
4748
"pytables": [null, ""], // platform dependent, see excludes below
4849
"tables": [null, ""],

asv_bench/benchmarks/attrs_caching.py

+33
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
import numpy as np
22

3+
import pandas as pd
34
from pandas import DataFrame
45

56
try:
67
from pandas.util import cache_readonly
78
except ImportError:
89
from pandas.util.decorators import cache_readonly
910

11+
try:
12+
from pandas.core.construction import extract_array
13+
except ImportError:
14+
extract_array = None
15+
1016

1117
class DataFrameAttributes:
1218
def setup(self):
@@ -20,6 +26,33 @@ def time_set_index(self):
2026
self.df.index = self.cur_index
2127

2228

29+
class SeriesArrayAttribute:
30+
31+
params = [["numeric", "object", "category", "datetime64", "datetime64tz"]]
32+
param_names = ["dtype"]
33+
34+
def setup(self, dtype):
35+
if dtype == "numeric":
36+
self.series = pd.Series([1, 2, 3])
37+
elif dtype == "object":
38+
self.series = pd.Series(["a", "b", "c"], dtype=object)
39+
elif dtype == "category":
40+
self.series = pd.Series(["a", "b", "c"], dtype="category")
41+
elif dtype == "datetime64":
42+
self.series = pd.Series(pd.date_range("2013", periods=3))
43+
elif dtype == "datetime64tz":
44+
self.series = pd.Series(pd.date_range("2013", periods=3, tz="UTC"))
45+
46+
def time_array(self, dtype):
47+
self.series.array
48+
49+
def time_extract_array(self, dtype):
50+
extract_array(self.series)
51+
52+
def time_extract_array_numpy(self, dtype):
53+
extract_array(self.series, extract_numpy=True)
54+
55+
2356
class CacheReadonly:
2457
def setup(self):
2558
class Foo:

asv_bench/benchmarks/pandas_vb_common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
def setup(*args, **kwargs):
5757
# This function just needs to be imported into each benchmark file to
5858
# set up the random seed before each function.
59-
# http://asv.readthedocs.io/en/latest/writing_benchmarks.html
59+
# https://asv.readthedocs.io/en/latest/writing_benchmarks.html
6060
np.random.seed(1234)
6161

6262

asv_bench/benchmarks/reshape.py

+3
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ def time_pivot_table_categorical_observed(self):
161161
observed=True,
162162
)
163163

164+
def time_pivot_table_margins_only_column(self):
165+
self.df.pivot_table(columns=["key2", "key3"], margins=True)
166+
164167

165168
class Crosstab:
166169
def setup(self):

asv_bench/benchmarks/rolling.py

+21
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,27 @@ def time_rolling(self, constructor, window, dtype, function, raw):
4444
self.roll.apply(function, raw=raw)
4545

4646

47+
class Engine:
48+
params = (
49+
["DataFrame", "Series"],
50+
["int", "float"],
51+
[np.sum, lambda x: np.sum(x) + 5],
52+
["cython", "numba"],
53+
)
54+
param_names = ["constructor", "dtype", "function", "engine"]
55+
56+
def setup(self, constructor, dtype, function, engine):
57+
N = 10 ** 3
58+
arr = (100 * np.random.random(N)).astype(dtype)
59+
self.data = getattr(pd, constructor)(arr)
60+
61+
def time_rolling_apply(self, constructor, dtype, function, engine):
62+
self.data.rolling(10).apply(function, raw=True, engine=engine)
63+
64+
def time_expanding_apply(self, constructor, dtype, function, engine):
65+
self.data.expanding().apply(function, raw=True, engine=engine)
66+
67+
4768
class ExpandingMethods:
4869

4970
params = (

asv_bench/benchmarks/tslibs/timedelta.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010

1111

1212
class TimedeltaConstructor:
13+
def setup(self):
14+
self.nptimedelta64 = np.timedelta64(3600)
15+
self.dttimedelta = datetime.timedelta(seconds=3600)
16+
self.td = Timedelta(3600, unit="s")
17+
1318
def time_from_int(self):
1419
Timedelta(123456789)
1520

@@ -28,10 +33,10 @@ def time_from_components(self):
2833
)
2934

3035
def time_from_datetime_timedelta(self):
31-
Timedelta(datetime.timedelta(days=1, seconds=1))
36+
Timedelta(self.dttimedelta)
3237

3338
def time_from_np_timedelta(self):
34-
Timedelta(np.timedelta64(1, "ms"))
39+
Timedelta(self.nptimedelta64)
3540

3641
def time_from_string(self):
3742
Timedelta("1 days")
@@ -42,6 +47,9 @@ def time_from_iso_format(self):
4247
def time_from_missing(self):
4348
Timedelta("nat")
4449

50+
def time_from_pd_timedelta(self):
51+
Timedelta(self.td)
52+
4553

4654
class TimedeltaProperties:
4755
def setup_cache(self):

0 commit comments

Comments
 (0)