Skip to content

Commit 369eead

Browse files
Merge branch 'master' into pandas-devGH-26206-datetime-unit-out-of-bounds
2 parents 968d854 + b9b081d commit 369eead

File tree

92 files changed

+993
-535
lines changed

Some content is hidden

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

92 files changed

+993
-535
lines changed

.travis.yml

-8
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,10 @@ matrix:
4848
env:
4949
- JOB="3.6, slow" ENV_FILE="ci/deps/travis-36-slow.yaml" PATTERN="slow"
5050

51-
# In allow_failures
52-
- dist: trusty
53-
env:
54-
- JOB="3.6, doc" ENV_FILE="ci/deps/travis-36-doc.yaml" DOC=true
5551
allow_failures:
5652
- dist: trusty
5753
env:
5854
- JOB="3.6, slow" ENV_FILE="ci/deps/travis-36-slow.yaml" PATTERN="slow"
59-
- dist: trusty
60-
env:
61-
- JOB="3.6, doc" ENV_FILE="ci/deps/travis-36-doc.yaml" DOC=true
6255

6356
before_install:
6457
- echo "before_install"
@@ -97,7 +90,6 @@ before_script:
9790
script:
9891
- echo "script start"
9992
- source activate pandas-dev
100-
- ci/build_docs.sh
10193
- ci/run_tests.sh
10294

10395
after_script:

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ Most development discussion is taking place on github in this repo. Further, the
224224

225225
All contributions, bug reports, bug fixes, documentation improvements, enhancements and ideas are welcome.
226226

227-
A detailed overview on how to contribute can be found in the **[contributing guide](https://pandas-docs.github.io/pandas-docs-travis/contributing.html)**. There is also an [overview](.github/CONTRIBUTING.md) on GitHub.
227+
A detailed overview on how to contribute can be found in the **[contributing guide](https://dev.pandas.io/contributing.html)**. There is also an [overview](.github/CONTRIBUTING.md) on GitHub.
228228

229229
If you are simply looking to start working with the pandas codebase, navigate to the [GitHub "issues" tab](https://github.com/pandas-dev/pandas/issues) and start looking through interesting issues. There are a number of issues listed under [Docs](https://github.com/pandas-dev/pandas/issues?labels=Docs&sort=updated&state=open) and [good first issue](https://github.com/pandas-dev/pandas/issues?labels=good+first+issue&sort=updated&state=open) where you could start out.
230230

asv_bench/benchmarks/ctors.py

+7
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,14 @@ class SeriesConstructors:
5555
[False, True],
5656
['float', 'int']]
5757

58+
# Generators get exhausted on use, so run setup before every call
59+
number = 1
60+
repeat = (3, 250, 10)
61+
5862
def setup(self, data_fmt, with_index, dtype):
63+
if data_fmt in (gen_of_str, gen_of_tuples) and with_index:
64+
raise NotImplementedError('Series constructors do not support '
65+
'using generators with indexes')
5966
N = 10**4
6067
if dtype == 'float':
6168
arr = np.random.randn(N)

asv_bench/benchmarks/frame_ctor.py

+4
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ class FromRecords:
7272
params = [None, 1000]
7373
param_names = ['nrows']
7474

75+
# Generators get exhausted on use, so run setup before every call
76+
number = 1
77+
repeat = (3, 250, 10)
78+
7579
def setup(self, nrows):
7680
N = 100000
7781
self.gen = ((x, (x * 20), (x * 100)) for x in range(N))

azure-pipelines.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ jobs:
123123
timeoutInMinutes: 90
124124
steps:
125125
- script: |
126-
echo '##vso[task.setvariable variable=ENV_FILE]ci/deps/travis-36-doc.yaml'
126+
echo '##vso[task.setvariable variable=ENV_FILE]environment.yml'
127127
displayName: 'Setting environment variables'
128128
129129
- script: |
@@ -146,6 +146,7 @@ jobs:
146146
git init
147147
touch .nojekyll
148148
echo "dev.pandas.io" > CNAME
149+
printf "User-agent: *\nDisallow: /" > robots.txt
149150
git add --all .
150151
git config user.email "[email protected]"
151152
git config user.name "pandas-docs-bot"
@@ -176,7 +177,6 @@ jobs:
176177
cd doc/build/html
177178
git remote add origin [email protected]:pandas-dev/pandas-dev.github.io.git
178179
git push -f origin master
179-
exit 0 # FIXME this will leave the build green even if the step fails. To be removed when we are confident with this.
180180
displayName: 'Publish docs to GitHub pages'
181181
condition : |
182182
and(not(eq(variables['Build.Reason'], 'PullRequest')),

ci/build_docs.sh

-56
This file was deleted.

ci/deps/travis-36-doc.yaml

-46
This file was deleted.

doc/source/development/contributing.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ Building master branch documentation
460460

461461
When pull requests are merged into the *pandas* ``master`` branch, the main parts of
462462
the documentation are also built by Travis-CI. These docs are then hosted `here
463-
<http://pandas-docs.github.io/pandas-docs-travis>`__, see also
463+
<https://dev.pandas.io>`__, see also
464464
the :ref:`Continuous Integration <contributing.ci>` section.
465465

466466
.. _contributing.code:

doc/source/install.rst

+1
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ psycopg2 PostgreSQL engine for sqlalchemy
286286
pyarrow 0.9.0 Parquet and feather reading / writing
287287
pymysql MySQL engine for sqlalchemy
288288
pyreadstat SPSS files (.sav) reading
289+
pytables 3.4.2 HDF5 reading / writing
289290
qtpy Clipboard I/O
290291
s3fs 0.0.8 Amazon S3 access
291292
xarray 0.8.2 pandas-like API for N-dimensional data

doc/source/user_guide/advanced.rst

+5-4
Original file line numberDiff line numberDiff line change
@@ -182,15 +182,15 @@ on a deeper level.
182182
Defined Levels
183183
~~~~~~~~~~~~~~
184184

185-
The repr of a ``MultiIndex`` shows all the defined levels of an index, even
185+
The :class:`MultiIndex` keeps all the defined levels of an index, even
186186
if they are not actually used. When slicing an index, you may notice this.
187187
For example:
188188

189189
.. ipython:: python
190190
191-
  df.columns # original MultiIndex
191+
  df.columns.levels # original MultiIndex
192192
193-
df[['foo','qux']].columns # sliced
193+
df[['foo','qux']].columns.levels # sliced
194194
195195
This is done to avoid a recomputation of the levels in order to make slicing
196196
highly performant. If you want to see only the used levels, you can use the
@@ -210,7 +210,8 @@ To reconstruct the ``MultiIndex`` with only the used levels, the
210210

211211
.. ipython:: python
212212
213-
df[['foo', 'qux']].columns.remove_unused_levels()
213+
new_mi = df[['foo', 'qux']].columns.remove_unused_levels()
214+
new_mi.levels
214215
215216
Data alignment and using ``reindex``
216217
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

doc/source/whatsnew/v0.25.0.rst

+37-1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,38 @@ a dict to a Series groupby aggregation (:ref:`whatsnew_0200.api_breaking.depreca
7474

7575
See :ref:`groupby.aggregate.named` for more.
7676

77+
78+
.. _whatsnew_0250.enhancements.multi_index_repr:
79+
80+
Better repr for MultiIndex
81+
^^^^^^^^^^^^^^^^^^^^^^^^^^
82+
83+
Printing of :class:`MultiIndex` instances now shows tuples of each row and ensures
84+
that the tuple items are vertically aligned, so it's now easier to understand
85+
the structure of the ``MultiIndex``. (:issue:`13480`):
86+
87+
The repr now looks like this:
88+
89+
.. ipython:: python
90+
91+
pd.MultiIndex.from_product([['a', 'abc'], range(500)])
92+
93+
Previously, outputting a :class:`MultiIndex` printed all the ``levels`` and
94+
``codes`` of the ``MultiIndex``, which was visually unappealing and made
95+
the output more difficult to navigate. For example (limiting the range to 5):
96+
97+
.. code-block:: ipython
98+
99+
In [1]: pd.MultiIndex.from_product([['a', 'abc'], range(5)])
100+
Out[1]: MultiIndex(levels=[['a', 'abc'], [0, 1, 2, 3]],
101+
...: codes=[[0, 0, 0, 0, 1, 1, 1, 1], [0, 1, 2, 3, 0, 1, 2, 3]])
102+
103+
In the new repr, all values will be shown, if the number of rows is smaller
104+
than :attr:`options.display.max_seq_items` (default: 100 items). Horizontally,
105+
the output will truncate, if it's wider than :attr:`options.display.width`
106+
(default: 80 characters).
107+
108+
77109
.. _whatsnew_0250.enhancements.other:
78110

79111
Other Enhancements
@@ -411,7 +443,7 @@ If installed, we now require:
411443
| pytest (dev) | 4.0.2 | |
412444
+-----------------+-----------------+----------+
413445

414-
For `optional libraries <https://pandas-docs.github.io/pandas-docs-travis/install.html#dependencies>`_ the general recommendation is to use the latest version.
446+
For `optional libraries <https://dev.pandas.io/install.html#dependencies>`_ the general recommendation is to use the latest version.
415447
The following table lists the lowest version per library that is currently being tested throughout the development of pandas.
416448
Optional libraries below the lowest tested version may still work, but are not considered supported.
417449

@@ -503,6 +535,7 @@ Other Deprecations
503535
- The :meth:`Series.ftype`, :meth:`Series.ftypes` and :meth:`DataFrame.ftypes` methods are deprecated and will be removed in a future version.
504536
Instead, use :meth:`Series.dtype` and :meth:`DataFrame.dtypes` (:issue:`26705`).
505537
- :meth:`Timedelta.resolution` is deprecated and replaced with :meth:`Timedelta.resolution_string`. In a future version, :meth:`Timedelta.resolution` will be changed to behave like the standard library :attr:`timedelta.resolution` (:issue:`21344`)
538+
- :meth:`Series.to_sparse`, :meth:`DataFrame.to_sparse`, :meth:`Series.to_dense` and :meth:`DataFrame.to_dense` are deprecated and will be removed in a future version. (:issue:`26557`).
506539

507540
.. _whatsnew_0250.prior_deprecations:
508541

@@ -568,6 +601,7 @@ Datetimelike
568601
- Bug in :func:`to_datetime` which raises ``TypeError`` for ``format='%Y%m%d'`` when called for invalid integer dates with length >= 6 digits with ``errors='ignore'``
569602
- Bug when comparing a :class:`PeriodIndex` against a zero-dimensional numpy array (:issue:`26689`)
570603
- Bug in constructing a ``Series`` or ``DataFrame`` from a numpy ``datetime64`` array with a non-ns unit and out-of-bound timestamps generating rubbish data, which will now correctly raise an ``OutOfBoundsDatetime`` error (:issue:`26206`).
604+
- Bug in :func:`date_range` with unnecessary ``OverflowError`` being raised for very large or very small dates (:issue:`26651`)
571605

572606
Timedelta
573607
^^^^^^^^^
@@ -710,6 +744,7 @@ Groupby/Resample/Rolling
710744
- Bug in :meth:`pandas.core.groupby.SeriesGroupBy.transform` where transforming an empty group would raise a ``ValueError`` (:issue:`26208`)
711745
- Bug in :meth:`pandas.core.frame.DataFrame.groupby` where passing a :class:`pandas.core.groupby.grouper.Grouper` would return incorrect groups when using the ``.groups`` accessor (:issue:`26326`)
712746
- Bug in :meth:`pandas.core.groupby.GroupBy.agg` where incorrect results are returned for uint64 columns. (:issue:`26310`)
747+
- Bug in :meth:`pandas.core.window.Rolling.median` and :meth:`pandas.core.window.Rolling.quantile` where MemoryError is raised with empty window (:issue:`26005`)
713748

714749
Reshaping
715750
^^^^^^^^^
@@ -737,6 +772,7 @@ Sparse
737772
- Bug in :class:`SparseFrame` constructor where passing ``None`` as the data would cause ``default_fill_value`` to be ignored (:issue:`16807`)
738773
- Bug in :class:`SparseDataFrame` when adding a column in which the length of values does not match length of index, ``AssertionError`` is raised instead of raising ``ValueError`` (:issue:`25484`)
739774
- Introduce a better error message in :meth:`Series.sparse.from_coo` so it returns a ``TypeError`` for inputs that are not coo matrices (:issue:`26554`)
775+
- Bug in :func:`numpy.modf` on a :class:`SparseArray`. Now a tuple of :class:`SparseArray` is returned.
740776

741777
Other
742778
^^^^^

pandas/_libs/tslibs/conversion.pyx

+9
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,10 @@ cdef convert_to_tsobject(object ts, object tz, object unit,
275275
- iso8601 string object
276276
- python datetime object
277277
- another timestamp object
278+
279+
Raises
280+
------
281+
OutOfBoundsDatetime : ts cannot be converted within implementation bounds
278282
"""
279283
cdef:
280284
_TSObject obj
@@ -294,6 +298,11 @@ cdef convert_to_tsobject(object ts, object tz, object unit,
294298
if obj.value != NPY_NAT:
295299
dt64_to_dtstruct(obj.value, &obj.dts)
296300
elif is_integer_object(ts):
301+
try:
302+
ts = <int64_t>ts
303+
except OverflowError:
304+
# GH#26651 re-raise as OutOfBoundsDatetime
305+
raise OutOfBoundsDatetime(ts)
297306
if ts == NPY_NAT:
298307
obj.value = NPY_NAT
299308
else:

pandas/_libs/window.pyx

+9
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,10 @@ def roll_median_c(ndarray[float64_t] values, int64_t win, int64_t minp,
10991099
use_mock=False)
11001100
output = np.empty(N, dtype=float)
11011101

1102+
if win == 0:
1103+
output[:] = NaN
1104+
return output
1105+
11021106
sl = skiplist_init(<int>win)
11031107
if sl == NULL:
11041108
raise MemoryError("skiplist_init failed")
@@ -1486,6 +1490,11 @@ def roll_quantile(ndarray[float64_t, cast=True] values, int64_t win,
14861490
minp, index, closed,
14871491
use_mock=False)
14881492
output = np.empty(N, dtype=float)
1493+
1494+
if win == 0:
1495+
output[:] = NaN
1496+
return output
1497+
14891498
skiplist = skiplist_init(<int>win)
14901499
if skiplist == NULL:
14911500
raise MemoryError("skiplist_init failed")

pandas/compat/_optional.py

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"s3fs": "0.0.8",
2020
"scipy": "0.19.0",
2121
"sqlalchemy": "1.1.4",
22+
"tables": "3.4.2",
2223
"xarray": "0.8.2",
2324
"xlrd": "1.1.0",
2425
"xlwt": "1.2.0",

pandas/compat/numpy/__init__.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
""" support numpy compatiblitiy across versions """
22

3-
import re
4-
import numpy as np
53
from distutils.version import LooseVersion
4+
import re
65

6+
import numpy as np
77

88
# numpy versioning
99
_np_version = np.__version__
@@ -62,6 +62,7 @@ def np_array_datetime64_compat(arr, *args, **kwargs):
6262

6363

6464
__all__ = ['np',
65+
'_np_version',
6566
'_np_version_under1p14',
6667
'_np_version_under1p15',
6768
'_np_version_under1p16',

pandas/core/accessor.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def decorator(accessor):
196196
return decorator
197197

198198

199-
_doc = """\
199+
_doc = """
200200
Register a custom accessor on %(klass)s objects.
201201
202202
Parameters

0 commit comments

Comments
 (0)