Skip to content

Commit 5e4b57b

Browse files
committed
Merge remote-tracking branch 'upstream/master' into docfix-multiindex-set_levels
2 parents de9058f + 2ec41bd commit 5e4b57b

File tree

340 files changed

+10452
-8725
lines changed

Some content is hidden

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

340 files changed

+10452
-8725
lines changed

.binstar.yml

-28
This file was deleted.

asv_bench/benchmarks/binary_ops.py

+32
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import operator
2+
13
import numpy as np
24

35
from pandas import DataFrame, Series, date_range
@@ -9,6 +11,36 @@
911
import pandas.computation.expressions as expr
1012

1113

14+
class IntFrameWithScalar:
15+
params = [
16+
[np.float64, np.int64],
17+
[2, 3.0, np.int32(4), np.float64(5)],
18+
[
19+
operator.add,
20+
operator.sub,
21+
operator.mul,
22+
operator.truediv,
23+
operator.floordiv,
24+
operator.pow,
25+
operator.mod,
26+
operator.eq,
27+
operator.ne,
28+
operator.gt,
29+
operator.ge,
30+
operator.lt,
31+
operator.le,
32+
],
33+
]
34+
param_names = ["dtype", "scalar", "op"]
35+
36+
def setup(self, dtype, scalar, op):
37+
arr = np.random.randn(20000, 100)
38+
self.df = DataFrame(arr.astype(dtype))
39+
40+
def time_frame_op_with_scalar(self, dtype, scalar, op):
41+
op(self.df, scalar)
42+
43+
1244
class Ops:
1345

1446
params = [[True, False], ["default", 1]]

asv_bench/benchmarks/dtypes.py

+22
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from .pandas_vb_common import (
66
datetime_dtypes,
77
extension_dtypes,
8+
lib,
89
numeric_dtypes,
910
string_dtypes,
1011
)
@@ -40,4 +41,25 @@ def time_pandas_dtype_invalid(self, dtype):
4041
pass
4142

4243

44+
class InferDtypes:
45+
param_names = ["dtype"]
46+
data_dict = {
47+
"np-object": np.array([1] * 100000, dtype="O"),
48+
"py-object": [1] * 100000,
49+
"np-null": np.array([1] * 50000 + [np.nan] * 50000),
50+
"py-null": [1] * 50000 + [None] * 50000,
51+
"np-int": np.array([1] * 100000, dtype=int),
52+
"np-floating": np.array([1.0] * 100000, dtype=float),
53+
"empty": [],
54+
"bytes": [b"a"] * 100000,
55+
}
56+
params = list(data_dict.keys())
57+
58+
def time_infer_skipna(self, dtype):
59+
lib.infer_dtype(self.data_dict[dtype], skipna=True)
60+
61+
def time_infer(self, dtype):
62+
lib.infer_dtype(self.data_dict[dtype], skipna=False)
63+
64+
4365
from .pandas_vb_common import setup # noqa: F401 isort:skip

asv_bench/benchmarks/tslibs/offsets.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def setup(self, offset):
5959

6060
def time_on_offset(self, offset):
6161
for date in self.dates:
62-
offset.onOffset(date)
62+
offset.is_on_offset(date)
6363

6464

6565
class OffestDatetimeArithmetic:

ci/azure/posix.yml

+2-9
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,13 @@ jobs:
6969
displayName: 'Build versions'
7070

7171
- task: PublishTestResults@2
72+
condition: succeededOrFailed()
7273
inputs:
74+
failTaskOnFailedTests: true
7375
testResultsFiles: 'test-data.xml'
7476
testRunTitle: ${{ format('{0}-$(CONDA_PY)', parameters.name) }}
7577
displayName: 'Publish test results'
7678

77-
- powershell: |
78-
$(Get-Content "test-data.xml" | Out-String) -match 'failures="(.*?)"'
79-
if ($matches[1] -eq 0) {
80-
Write-Host "No test failures in test-data"
81-
} else {
82-
Write-Error "$($matches[1]) tests failed" # will produce $LASTEXITCODE=1
83-
}
84-
displayName: 'Check for test failures'
85-
8679
- script: |
8780
source activate pandas-dev
8881
python ci/print_skipped.py

ci/azure/windows.yml

+12-10
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,34 @@ jobs:
2323
Write-Host "##vso[task.prependpath]$env:CONDA\Scripts"
2424
Write-Host "##vso[task.prependpath]$HOME/miniconda3/bin"
2525
displayName: 'Add conda to PATH'
26+
2627
- script: conda update -q -n base conda
2728
displayName: 'Update conda'
29+
2830
- bash: |
2931
conda env create -q --file ci\\deps\\azure-windows-$(CONDA_PY).yaml
3032
displayName: 'Create anaconda environment'
33+
3134
- bash: |
3235
source activate pandas-dev
3336
conda list
34-
ci\\incremental\\build.cmd
37+
python setup.py build_ext -q -i
38+
python -m pip install --no-build-isolation -e .
3539
displayName: 'Build'
40+
3641
- bash: |
3742
source activate pandas-dev
3843
ci/run_tests.sh
3944
displayName: 'Test'
45+
4046
- task: PublishTestResults@2
47+
condition: succeededOrFailed()
4148
inputs:
49+
failTaskOnFailedTests: true
4250
testResultsFiles: 'test-data.xml'
43-
testRunTitle: 'Windows-$(CONDA_PY)'
44-
- powershell: |
45-
$(Get-Content "test-data.xml" | Out-String) -match 'failures="(.*?)"'
46-
if ($matches[1] -eq 0) {
47-
Write-Host "No test failures in test-data"
48-
} else {
49-
Write-Error "$($matches[1]) tests failed" # will produce $LASTEXITCODE=1
50-
}
51-
displayName: 'Check for test failures'
51+
testRunTitle: ${{ format('{0}-$(CONDA_PY)', parameters.name) }}
52+
displayName: 'Publish test results'
53+
5254
- bash: |
5355
source activate pandas-dev
5456
python ci/print_skipped.py

ci/code_checks.sh

+15-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ if [[ -z "$CHECK" || "$CHECK" == "lint" ]]; then
5252
black --version
5353

5454
MSG='Checking black formatting' ; echo $MSG
55-
black . --check
55+
black . --check
5656
RET=$(($RET + $?)) ; echo $MSG "DONE"
5757

5858
# `setup.cfg` contains the list of error codes that are being ignored in flake8
@@ -104,7 +104,7 @@ if [[ -z "$CHECK" || "$CHECK" == "lint" ]]; then
104104
isort --version-number
105105

106106
# Imports - Check formatting using isort see setup.cfg for settings
107-
MSG='Check import format using isort ' ; echo $MSG
107+
MSG='Check import format using isort' ; echo $MSG
108108
ISORT_CMD="isort --recursive --check-only pandas asv_bench"
109109
if [[ "$GITHUB_ACTIONS" == "true" ]]; then
110110
eval $ISORT_CMD | awk '{print "##[error]" $0}'; RET=$(($RET + ${PIPESTATUS[0]}))
@@ -122,13 +122,18 @@ if [[ -z "$CHECK" || "$CHECK" == "patterns" ]]; then
122122
# Check for imports from collections.abc instead of `from collections import abc`
123123
MSG='Check for non-standard imports' ; echo $MSG
124124
invgrep -R --include="*.py*" -E "from pandas.core.common import" pandas
125+
RET=$(($RET + $?)) ; echo $MSG "DONE"
125126
invgrep -R --include="*.py*" -E "from pandas.core import common" pandas
127+
RET=$(($RET + $?)) ; echo $MSG "DONE"
126128
invgrep -R --include="*.py*" -E "from collections.abc import" pandas
129+
RET=$(($RET + $?)) ; echo $MSG "DONE"
127130
invgrep -R --include="*.py*" -E "from numpy import nan" pandas
131+
RET=$(($RET + $?)) ; echo $MSG "DONE"
128132

129133
# Checks for test suite
130134
# Check for imports from pandas.util.testing instead of `import pandas.util.testing as tm`
131135
invgrep -R --include="*.py*" -E "from pandas.util.testing import" pandas/tests
136+
RET=$(($RET + $?)) ; echo $MSG "DONE"
132137
invgrep -R --include="*.py*" -E "from pandas.util import testing as tm" pandas/tests
133138
RET=$(($RET + $?)) ; echo $MSG "DONE"
134139

@@ -195,6 +200,10 @@ if [[ -z "$CHECK" || "$CHECK" == "patterns" ]]; then
195200
invgrep -R --include="*.py" --include="*.pyx" -E 'class.*:\n\n( )+"""' .
196201
RET=$(($RET + $?)) ; echo $MSG "DONE"
197202

203+
MSG='Check for use of {foo!r} instead of {repr(foo)}' ; echo $MSG
204+
invgrep -R --include=*.{py,pyx} '!r}' pandas
205+
RET=$(($RET + $?)) ; echo $MSG "DONE"
206+
198207
MSG='Check for use of comment-based annotation syntax' ; echo $MSG
199208
invgrep -R --include="*.py" -P '# type: (?!ignore)' pandas
200209
RET=$(($RET + $?)) ; echo $MSG "DONE"
@@ -203,6 +212,10 @@ if [[ -z "$CHECK" || "$CHECK" == "patterns" ]]; then
203212
invgrep -R --include=*.{py,pyx} '\.__class__' pandas
204213
RET=$(($RET + $?)) ; echo $MSG "DONE"
205214

215+
MSG='Check for use of xrange instead of range' ; echo $MSG
216+
invgrep -R --include=*.{py,pyx} 'xrange' pandas
217+
RET=$(($RET + $?)) ; echo $MSG "DONE"
218+
206219
MSG='Check that no file in the repo contains trailing whitespaces' ; echo $MSG
207220
INVGREP_APPEND=" <- trailing whitespaces found"
208221
invgrep -RI --exclude=\*.{svg,c,cpp,html,js} --exclude-dir=env "\s$" *

ci/deps/azure-36-minimum_versions.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ dependencies:
1717
- beautifulsoup4=4.6.0
1818
- bottleneck=1.2.1
1919
- jinja2=2.8
20+
- numba=0.46.0
2021
- numexpr=2.6.2
2122
- numpy=1.13.3
2223
- openpyxl=2.5.7

ci/deps/azure-windows-36.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ dependencies:
1717
- bottleneck
1818
- fastparquet>=0.3.2
1919
- matplotlib=3.0.2
20+
- numba
2021
- numexpr
2122
- numpy=1.15.*
2223
- openpyxl

ci/deps/travis-37.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ dependencies:
2020
- pyarrow
2121
- pytz
2222
- s3fs
23+
- tabulate
2324
- pyreadstat
2425
- pip
2526
- pip:

ci/deps/travis-38.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ dependencies:
1717
- nomkl
1818
- pytz
1919
- pip
20+
- tabulate==0.8.3

ci/incremental/build.cmd

-9
This file was deleted.

ci/run_tests.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ sh -c "$PYTEST_CMD"
3838

3939
if [[ "$COVERAGE" && $? == 0 && "$TRAVIS_BRANCH" == "master" ]]; then
4040
echo "uploading coverage"
41-
echo "bash <(curl -s https://codecov.io/bash) -Z -c -F $TYPE -f $COVERAGE_FNAME"
42-
bash <(curl -s https://codecov.io/bash) -Z -c -F $TYPE -f $COVERAGE_FNAME
41+
echo "bash <(curl -s https://codecov.io/bash) -Z -c -f $COVERAGE_FNAME"
42+
bash <(curl -s https://codecov.io/bash) -Z -c -f $COVERAGE_FNAME
4343
fi

ci/setup_env.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ conda list pandas
121121
# Make sure any error below is reported as such
122122

123123
echo "[Build extensions]"
124-
python setup.py build_ext -q -i
124+
python setup.py build_ext -q -i -j2
125125

126126
# XXX: Some of our environments end up with old versions of pip (10.x)
127127
# Adding a new enough version of pip to the requirements explodes the

doc/redirects.csv

+1-1
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ generated/pandas.io.formats.style.Styler.to_excel,../reference/api/pandas.io.for
777777
generated/pandas.io.formats.style.Styler.use,../reference/api/pandas.io.formats.style.Styler.use
778778
generated/pandas.io.formats.style.Styler.where,../reference/api/pandas.io.formats.style.Styler.where
779779
generated/pandas.io.json.build_table_schema,../reference/api/pandas.io.json.build_table_schema
780-
generated/pandas.io.json.json_normalize,../reference/api/pandas.io.json.json_normalize
780+
generated/pandas.io.json.json_normalize,../reference/api/pandas.json_normalize
781781
generated/pandas.io.stata.StataReader.data_label,../reference/api/pandas.io.stata.StataReader.data_label
782782
generated/pandas.io.stata.StataReader.value_labels,../reference/api/pandas.io.stata.StataReader.value_labels
783783
generated/pandas.io.stata.StataReader.variable_labels,../reference/api/pandas.io.stata.StataReader.variable_labels

doc/source/_static/favicon.ico

-3.81 KB
Binary file not shown.

doc/source/conf.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,11 @@
204204
# Theme options are theme-specific and customize the look and feel of a theme
205205
# further. For a list of options available for each theme, see the
206206
# documentation.
207-
# html_theme_options = {}
207+
html_theme_options = {
208+
"external_links": [],
209+
"github_url": "https://github.com/pandas-dev/pandas",
210+
"twitter_url": "https://twitter.com/pandas_dev",
211+
}
208212

209213
# Add any paths that contain custom themes here, relative to this directory.
210214
# html_theme_path = ["themes"]
@@ -228,7 +232,7 @@
228232
# The name of an image file (within the static path) to use as favicon of the
229233
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
230234
# pixels large.
231-
html_favicon = os.path.join(html_static_path[0], "favicon.ico")
235+
html_favicon = "../../web/pandas/static/img/favicon.ico"
232236

233237
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
234238
# using the given strftime format.

doc/source/getting_started/install.rst

+5-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@ Optional dependencies
234234
~~~~~~~~~~~~~~~~~~~~~
235235

236236
Pandas has many optional dependencies that are only used for specific methods.
237-
For example, :func:`pandas.read_hdf` requires the ``pytables`` package. If the
237+
For example, :func:`pandas.read_hdf` requires the ``pytables`` package, while
238+
:meth:`DataFrame.to_markdown` requires the ``tabulate`` package. If the
238239
optional dependency is not installed, pandas will raise an ``ImportError`` when
239240
the method requiring that dependency is called.
240241

@@ -255,6 +256,7 @@ gcsfs 0.2.2 Google Cloud Storage access
255256
html5lib HTML parser for read_html (see :ref:`note <optional_html>`)
256257
lxml 3.8.0 HTML parser for read_html (see :ref:`note <optional_html>`)
257258
matplotlib 2.2.2 Visualization
259+
numba 0.46.0 Alternative execution engine for rolling operations
258260
openpyxl 2.5.7 Reading / writing for xlsx files
259261
pandas-gbq 0.8.0 Google Big Query access
260262
psycopg2 PostgreSQL engine for sqlalchemy
@@ -264,6 +266,7 @@ pyreadstat SPSS files (.sav) reading
264266
pytables 3.4.2 HDF5 reading / writing
265267
qtpy Clipboard I/O
266268
s3fs 0.3.0 Amazon S3 access
269+
tabulate 0.8.3 Printing in Markdown-friendly format (see `tabulate`_)
267270
xarray 0.8.2 pandas-like API for N-dimensional data
268271
xclip Clipboard I/O on linux
269272
xlrd 1.1.0 Excel reading
@@ -301,3 +304,4 @@ top-level :func:`~pandas.read_html` function:
301304
.. _html5lib: https://github.com/html5lib/html5lib-python
302305
.. _BeautifulSoup4: http://www.crummy.com/software/BeautifulSoup
303306
.. _lxml: http://lxml.de
307+
.. _tabulate: https://github.com/astanin/python-tabulate

doc/source/reference/frame.rst

+1
Original file line numberDiff line numberDiff line change
@@ -361,4 +361,5 @@ Serialization / IO / conversion
361361
DataFrame.to_records
362362
DataFrame.to_string
363363
DataFrame.to_clipboard
364+
DataFrame.to_markdown
364365
DataFrame.style

doc/source/reference/io.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ JSON
5050
:toctree: api/
5151

5252
read_json
53+
json_normalize
5354

5455
.. currentmodule:: pandas.io.json
5556

5657
.. autosummary::
5758
:toctree: api/
5859

59-
json_normalize
6060
build_table_schema
6161

6262
.. currentmodule:: pandas

0 commit comments

Comments
 (0)