Skip to content

Commit 5420f25

Browse files
Merge branch 'master' into issue_backupbackup
2 parents d3f868c + b2c7519 commit 5420f25

File tree

281 files changed

+7806
-9271
lines changed

Some content is hidden

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

281 files changed

+7806
-9271
lines changed

.github/CONTRIBUTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ Our main contributing guide can be found [in this repo](https://github.com/panda
88

99
If you are looking to contribute to the *pandas* codebase, the best place to start is the [GitHub "issues" tab](https://github.com/pandas-dev/pandas/issues). This is also a great place for filing bug reports and making suggestions for ways in which we can improve the code and documentation.
1010

11-
If you have additional questions, feel free to ask them on the [mailing list](https://groups.google.com/forum/?fromgroups#!forum/pydata) or on [Gitter](https://gitter.im/pydata/pandas). Further information can also be found in the "[Where to start?](https://github.com/pandas-dev/pandas/blob/master/doc/source/contributing.rst#where-to-start)" section.
11+
If you have additional questions, feel free to ask them on the [mailing list](https://groups.google.com/forum/?fromgroups#!forum/pydata) or on [Gitter](https://gitter.im/pydata/pandas). Further information can also be found in the "[Where to start?](https://github.com/pandas-dev/pandas/blob/master/doc/source/development/contributing.rst#where-to-start)" section.
1212

1313
## Filing Issues
1414

15-
If you notice a bug in the code or documentation, or have suggestions for how we can improve either, feel free to create an issue on the [GitHub "issues" tab](https://github.com/pandas-dev/pandas/issues) using [GitHub's "issue" form](https://github.com/pandas-dev/pandas/issues/new). The form contains some questions that will help us best address your issue. For more information regarding how to file issues against *pandas*, please refer to the "[Bug reports and enhancement requests](https://github.com/pandas-dev/pandas/blob/master/doc/source/contributing.rst#bug-reports-and-enhancement-requests)" section.
15+
If you notice a bug in the code or documentation, or have suggestions for how we can improve either, feel free to create an issue on the [GitHub "issues" tab](https://github.com/pandas-dev/pandas/issues) using [GitHub's "issue" form](https://github.com/pandas-dev/pandas/issues/new). The form contains some questions that will help us best address your issue. For more information regarding how to file issues against *pandas*, please refer to the "[Bug reports and enhancement requests](https://github.com/pandas-dev/pandas/blob/master/doc/source/development/contributing.rst#bug-reports-and-enhancement-requests)" section.
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/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](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.
2020

21-
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/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/contributing.rst#code-standards)" section.
21+
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/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

23-
Once your changes are ready to be submitted, make sure to push your changes to GitHub before creating a pull request. Details about how to do that can be found in the "[Contributing your changes to pandas](https://github.com/pandas-dev/pandas/blob/master/doc/source/contributing.rst#contributing-your-changes-to-pandas)" section. We will review your changes, and you will most likely be asked to make additional changes before it is finally ready to merge. However, once it's ready, we will merge it, and you will have successfully contributed to the codebase!
23+
Once your changes are ready to be submitted, make sure to push your changes to GitHub before creating a pull request. Details about how to do that can be found in the "[Contributing your changes to pandas](https://github.com/pandas-dev/pandas/blob/master/doc/source/development/contributing.rst#contributing-your-changes-to-pandas)" section. We will review your changes, and you will most likely be asked to make additional changes before it is finally ready to merge. However, once it's ready, we will merge it, and you will have successfully contributed to the codebase!

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,3 @@ doc:
2323
cd doc; \
2424
python make.py clean; \
2525
python make.py html
26-
python make.py spellcheck

asv_bench/benchmarks/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Pandas benchmarks."""

asv_bench/benchmarks/algorithms.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import pandas as pd
66
from pandas.util import testing as tm
77

8-
98
for imp in ['pandas.util', 'pandas.tools.hashing']:
109
try:
1110
hashing = import_module(imp)
@@ -142,4 +141,4 @@ def time_quantile(self, quantile, interpolation, dtype):
142141
self.idx.quantile(quantile, interpolation=interpolation)
143142

144143

145-
from .pandas_vb_common import setup # noqa: F401
144+
from .pandas_vb_common import setup # noqa: F401 isort:skip

asv_bench/benchmarks/io/hdf.py

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import warnings
2-
31
import numpy as np
4-
from pandas import DataFrame, Panel, date_range, HDFStore, read_hdf
2+
from pandas import DataFrame, date_range, HDFStore, read_hdf
53
import pandas.util.testing as tm
64

75
from ..pandas_vb_common import BaseIO
@@ -99,31 +97,6 @@ def time_store_info(self):
9997
self.store.info()
10098

10199

102-
class HDFStorePanel(BaseIO):
103-
104-
def setup(self):
105-
self.fname = '__test__.h5'
106-
with warnings.catch_warnings(record=True):
107-
self.p = Panel(np.random.randn(20, 1000, 25),
108-
items=['Item%03d' % i for i in range(20)],
109-
major_axis=date_range('1/1/2000', periods=1000),
110-
minor_axis=['E%03d' % i for i in range(25)])
111-
self.store = HDFStore(self.fname)
112-
self.store.append('p1', self.p)
113-
114-
def teardown(self):
115-
self.store.close()
116-
self.remove(self.fname)
117-
118-
def time_read_store_table_panel(self):
119-
with warnings.catch_warnings(record=True):
120-
self.store.select('p1')
121-
122-
def time_write_store_table_panel(self):
123-
with warnings.catch_warnings(record=True):
124-
self.store.append('p2', self.p)
125-
126-
127100
class HDF(BaseIO):
128101

129102
params = ['table', 'fixed']

asv_bench/benchmarks/strings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ def setup(self, repeats):
102102
N = 10**5
103103
self.s = Series(tm.makeStringIndex(N))
104104
repeat = {'int': 1, 'array': np.random.randint(1, 3, N)}
105-
self.repeat = repeat[repeats]
105+
self.values = repeat[repeats]
106106

107107
def time_repeat(self, repeats):
108-
self.s.str.repeat(self.repeat)
108+
self.s.str.repeat(self.values)
109109

110110

111111
class Cat(object):

ci/code_checks.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ if [[ -z "$CHECK" || "$CHECK" == "lint" ]]; then
9393
# this particular codebase (e.g. src/headers, src/klib, src/msgpack). However,
9494
# we can lint all header files since they aren't "generated" like C files are.
9595
MSG='Linting .c and .h' ; echo $MSG
96-
cpplint --quiet --extensions=c,h --headers=h --recursive --filter=-readability/casting,-runtime/int,-build/include_subdir pandas/_libs/src/*.h pandas/_libs/src/parser pandas/_libs/ujson pandas/_libs/tslibs/src/datetime
96+
cpplint --quiet --extensions=c,h --headers=h --recursive --filter=-readability/casting,-runtime/int,-build/include_subdir pandas/_libs/src/*.h pandas/_libs/src/parser pandas/_libs/ujson pandas/_libs/tslibs/src/datetime pandas/io/msgpack pandas/_libs/*.cpp pandas/util
9797
RET=$(($RET + $?)) ; echo $MSG "DONE"
9898

9999
echo "isort --version-number"
@@ -174,9 +174,10 @@ if [[ -z "$CHECK" || "$CHECK" == "patterns" ]]; then
174174
MSG='Check that no file in the repo contains tailing whitespaces' ; echo $MSG
175175
set -o pipefail
176176
if [[ "$AZURE" == "true" ]]; then
177-
! grep -n --exclude="*.svg" -RI "\s$" * | awk -F ":" '{print "##vso[task.logissue type=error;sourcepath=" $1 ";linenumber=" $2 ";] Tailing whitespaces found: " $3}'
177+
# we exclude all c/cpp files as the c/cpp files of pandas code base are tested when Linting .c and .h files
178+
! grep -n '--exclude=*.'{svg,c,cpp,html} -RI "\s$" * | awk -F ":" '{print "##vso[task.logissue type=error;sourcepath=" $1 ";linenumber=" $2 ";] Tailing whitespaces found: " $3}'
178179
else
179-
! grep -n --exclude="*.svg" -RI "\s$" * | awk -F ":" '{print $1 ":" $2 ":Tailing whitespaces found: " $3}'
180+
! grep -n '--exclude=*.'{svg,c,cpp,html} -RI "\s$" * | awk -F ":" '{print $1 ":" $2 ":Tailing whitespaces found: " $3}'
180181
fi
181182
RET=$(($RET + $?)) ; echo $MSG "DONE"
182183
fi
@@ -206,7 +207,7 @@ if [[ -z "$CHECK" || "$CHECK" == "doctests" ]]; then
206207

207208
MSG='Doctests frame.py' ; echo $MSG
208209
pytest -q --doctest-modules pandas/core/frame.py \
209-
-k"-axes -combine -itertuples -join -pivot_table -query -reindex -reindex_axis -round"
210+
-k" -itertuples -join -reindex -reindex_axis -round"
210211
RET=$(($RET + $?)) ; echo $MSG "DONE"
211212

212213
MSG='Doctests series.py' ; echo $MSG
@@ -240,8 +241,8 @@ fi
240241
### DOCSTRINGS ###
241242
if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
242243

243-
MSG='Validate docstrings (GL06, GL07, GL09, SS04, PR03, PR05, EX04)' ; echo $MSG
244-
$BASE_DIR/scripts/validate_docstrings.py --format=azure --errors=GL06,GL07,GL09,SS04,PR03,PR05,EX04
244+
MSG='Validate docstrings (GL06, GL07, GL09, SS04, PR03, PR05, PR10, EX04, RT04, RT05, SS05, SA05)' ; echo $MSG
245+
$BASE_DIR/scripts/validate_docstrings.py --format=azure --errors=GL06,GL07,GL09,SS04,PR03,PR04,PR05,EX04,RT04,RT05,SS05,SA05
245246
RET=$(($RET + $?)) ; echo $MSG "DONE"
246247

247248
fi

ci/deps/azure-27-compat.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ dependencies:
2020
# universal
2121
- pytest
2222
- pytest-xdist
23+
- pytest-mock
2324
- pip:
2425
- html5lib==1.0b2
2526
- beautifulsoup4==4.2.1

ci/deps/azure-27-locale.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ dependencies:
2222
# universal
2323
- pytest
2424
- pytest-xdist
25+
- pytest-mock
2526
- hypothesis>=3.58.0
2627
- pip:
2728
- html5lib==1.0b2

ci/deps/azure-36-locale_slow.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ dependencies:
2828
# universal
2929
- pytest
3030
- pytest-xdist
31+
- pytest-mock
3132
- moto
3233
- pip:
3334
- hypothesis>=3.58.0

ci/deps/azure-37-locale.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ dependencies:
2727
# universal
2828
- pytest
2929
- pytest-xdist
30+
- pytest-mock
3031
- pip:
3132
- hypothesis>=3.58.0
3233
- moto # latest moto in conda-forge fails with 3.7, move to conda dependencies when this is fixed

ci/deps/azure-37-numpydev.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ dependencies:
88
# universal
99
- pytest
1010
- pytest-xdist
11+
- pytest-mock
1112
- hypothesis>=3.58.0
1213
- pip:
1314
- "git+git://github.com/dateutil/dateutil.git"

ci/deps/azure-macos-35.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ dependencies:
2424
# universal
2525
- pytest
2626
- pytest-xdist
27+
- pytest-mock
2728
- pip:
2829
- python-dateutil==2.5.3
2930
- hypothesis>=3.58.0

ci/deps/azure-windows-27.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@ dependencies:
2727
- cython>=0.28.2
2828
- pytest
2929
- pytest-xdist
30+
- pytest-mock
3031
- moto
3132
- hypothesis>=3.58.0

ci/deps/azure-windows-36.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ dependencies:
2525
- cython>=0.28.2
2626
- pytest
2727
- pytest-xdist
28+
- pytest-mock
2829
- hypothesis>=3.58.0

ci/deps/travis-27.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ dependencies:
4141
# universal
4242
- pytest
4343
- pytest-xdist
44+
- pytest-mock
4445
- moto==1.3.4
4546
- hypothesis>=3.58.0
4647
- pip:

ci/deps/travis-36-locale.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ dependencies:
3030
# universal
3131
- pytest
3232
- pytest-xdist
33+
- pytest-mock
3334
- moto
3435
- pip:
3536
- hypothesis>=3.58.0

ci/deps/travis-36-slow.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@ dependencies:
2727
# universal
2828
- pytest
2929
- pytest-xdist
30+
- pytest-mock
3031
- moto
3132
- hypothesis>=3.58.0

ci/deps/travis-36.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ dependencies:
3636
- pytest
3737
- pytest-xdist
3838
- pytest-cov
39+
- pytest-mock
3940
- hypothesis>=3.58.0
4041
- pip:
4142
- brotlipy

ci/deps/travis-37.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ dependencies:
1414
- pytz
1515
- pytest
1616
- pytest-xdist
17+
- pytest-mock
1718
- hypothesis>=3.58.0
1819
- s3fs
1920
- pip:

doc/cheatsheet/Pandas_Cheat_Sheet.pdf

6.61 KB
Binary file not shown.
13 Bytes
Binary file not shown.
209 KB
Binary file not shown.
5.93 KB
Binary file not shown.

doc/source/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@
9898
if (fname == 'index.rst'
9999
and os.path.abspath(dirname) == source_path):
100100
continue
101-
elif pattern == '-api' and dirname == 'api':
101+
elif pattern == '-api' and dirname == 'reference':
102102
exclude_patterns.append(fname)
103-
elif fname != pattern:
103+
elif pattern != '-api' and fname != pattern:
104104
exclude_patterns.append(fname)
105105

106106
with open(os.path.join(source_path, 'index.rst.template')) as f:

doc/source/development/contributing.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Bug reports must:
5454
...
5555
```
5656

57-
#. Include the full version string of *pandas* and its dependencies. You can use the built in function::
57+
#. Include the full version string of *pandas* and its dependencies. You can use the built-in function::
5858

5959
>>> import pandas as pd
6060
>>> pd.show_versions()
@@ -211,7 +211,7 @@ See the full conda docs `here <http://conda.pydata.org/docs>`__.
211211
Creating a Python Environment (pip)
212212
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
213213

214-
If you aren't using conda for you development environment, follow these instructions.
214+
If you aren't using conda for your development environment, follow these instructions.
215215
You'll need to have at least python3.5 installed on your system.
216216

217217
.. code-block:: none
@@ -484,7 +484,7 @@ contributing them to the project::
484484

485485
./ci/code_checks.sh
486486

487-
The script verify the linting of code files, it looks for common mistake patterns
487+
The script verifies the linting of code files, it looks for common mistake patterns
488488
(like missing spaces around sphinx directives that make the documentation not
489489
being rendered properly) and it also validates the doctests. It is possible to
490490
run the checks independently by using the parameters ``lint``, ``patterns`` and
@@ -675,7 +675,7 @@ Otherwise, you need to do it manually:
675675
676676
You'll also need to
677677

678-
1. write a new test that asserts a warning is issued when calling with the deprecated argument
678+
1. Write a new test that asserts a warning is issued when calling with the deprecated argument
679679
2. Update all of pandas existing tests and code to use the new argument
680680

681681
See :ref:`contributing.warnings` for more.

doc/source/getting_started/basics.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ So, for instance, to reproduce :meth:`~DataFrame.combine_first` as above:
505505
.. ipython:: python
506506
507507
def combiner(x, y):
508-
np.where(pd.isna(x), y, x)
508+
return np.where(pd.isna(x), y, x)
509509
df1.combine(df2, combiner)
510510
511511
.. _basics.stats:

doc/source/reference/arrays.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ Methods
120120
Timestamp.timetuple
121121
Timestamp.timetz
122122
Timestamp.to_datetime64
123+
Timestamp.to_numpy
123124
Timestamp.to_julian_date
124125
Timestamp.to_period
125126
Timestamp.to_pydatetime
@@ -191,6 +192,7 @@ Methods
191192
Timedelta.round
192193
Timedelta.to_pytimedelta
193194
Timedelta.to_timedelta64
195+
Timedelta.to_numpy
194196
Timedelta.total_seconds
195197

196198
A collection of timedeltas may be stored in a :class:`TimedeltaArray`.

doc/source/user_guide/groupby.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ steps:
1515

1616
Out of these, the split step is the most straightforward. In fact, in many
1717
situations we may wish to split the data set into groups and do something with
18-
those groups. In the apply step, we might wish to one of the
18+
those groups. In the apply step, we might wish to do one of the
1919
following:
2020

2121
* **Aggregation**: compute a summary statistic (or statistics) for each
@@ -1317,7 +1317,7 @@ arbitrary function, for example:
13171317
df.groupby(['Store', 'Product']).pipe(mean)
13181318
13191319
where ``mean`` takes a GroupBy object and finds the mean of the Revenue and Quantity
1320-
columns repectively for each Store-Product combination. The ``mean`` function can
1320+
columns respectively for each Store-Product combination. The ``mean`` function can
13211321
be any function that takes in a GroupBy object; the ``.pipe`` will pass the GroupBy
13221322
object as a parameter into the function you specify.
13231323

doc/source/user_guide/io.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,36 @@ a single date rather than the entire array.
989989
990990
os.remove('tmp.csv')
991991
992+
993+
.. _io.csv.mixed_timezones:
994+
995+
Parsing a CSV with mixed Timezones
996+
++++++++++++++++++++++++++++++++++
997+
998+
Pandas cannot natively represent a column or index with mixed timezones. If your CSV
999+
file contains columns with a mixture of timezones, the default result will be
1000+
an object-dtype column with strings, even with ``parse_dates``.
1001+
1002+
1003+
.. ipython:: python
1004+
1005+
content = """\
1006+
a
1007+
2000-01-01T00:00:00+05:00
1008+
2000-01-01T00:00:00+06:00"""
1009+
df = pd.read_csv(StringIO(content), parse_dates=['a'])
1010+
df['a']
1011+
1012+
To parse the mixed-timezone values as a datetime column, pass a partially-applied
1013+
:func:`to_datetime` with ``utc=True`` as the ``date_parser``.
1014+
1015+
.. ipython:: python
1016+
1017+
df = pd.read_csv(StringIO(content), parse_dates=['a'],
1018+
date_parser=lambda col: pd.to_datetime(col, utc=True))
1019+
df['a']
1020+
1021+
9921022
.. _io.dayfirst:
9931023

9941024

0 commit comments

Comments
 (0)