Skip to content

Commit 1bd7936

Browse files
committed
Merge branch 'master' of https://github.com/pandas-dev/pandas into inline_cleanup
2 parents df725d3 + d1fe892 commit 1bd7936

File tree

17 files changed

+209
-112
lines changed

17 files changed

+209
-112
lines changed

asv_bench/benchmarks/index_object.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,23 @@ def time_datetime_level_values_full(self):
199199

200200
def time_datetime_level_values_sliced(self):
201201
self.mi[:10].values
202+
203+
204+
class Range(object):
205+
goal_time = 0.2
206+
207+
def setup(self):
208+
self.idx_inc = RangeIndex(start=0, stop=10**7, step=3)
209+
self.idx_dec = RangeIndex(start=10**7, stop=-1, step=-3)
210+
211+
def time_max(self):
212+
self.idx_inc.max()
213+
214+
def time_max_trivial(self):
215+
self.idx_dec.max()
216+
217+
def time_min(self):
218+
self.idx_dec.min()
219+
220+
def time_min_trivial(self):
221+
self.idx_inc.min()

asv_bench/benchmarks/timestamp.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,9 @@ def time_replace_across_dst(self):
8181

8282
def time_replace_None(self):
8383
self.ts_tz.replace(tzinfo=None)
84+
85+
def time_to_pydatetime(self):
86+
self.ts.to_pydatetime()
87+
88+
def time_to_pydatetime_tz(self):
89+
self.ts_tz.to_pydatetime()

ci/requirements-3.6.build

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,5 @@ python=3.6*
22
python-dateutil
33
pytz
44
nomkl
5+
numpy
56
cython
6-
7-
# pin numpy that is built for all our deps
8-
numpy=1.13.1=py36_blas_openblas_201

doc/source/api.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,6 +1416,20 @@ Selecting
14161416
Index.slice_indexer
14171417
Index.slice_locs
14181418

1419+
.. _api.numericindex:
1420+
1421+
Numeric Index
1422+
-------------
1423+
1424+
.. autosummary::
1425+
:toctree: generated/
1426+
:template: autosummary/class_without_autosummary.rst
1427+
1428+
RangeIndex
1429+
Int64Index
1430+
UInt64Index
1431+
Float64Index
1432+
14191433
.. _api.categoricalindex:
14201434

14211435
CategoricalIndex

doc/source/whatsnew/v0.21.0.txt

Lines changed: 60 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ Other Enhancements
116116
- :func:`Styler.where` has been implemented. It is as a convenience for :func:`Styler.applymap` and enables simple DataFrame styling on the Jupyter notebook (:issue:`17474`).
117117
- :func:`MultiIndex.is_monotonic_decreasing` has been implemented. Previously returned ``False`` in all cases. (:issue:`16554`)
118118
- :func:`Categorical.rename_categories` now accepts a dict-like argument as `new_categories` and only updates the categories found in that dict. (:issue:`17336`)
119+
- :func:`read_excel` raises ``ImportError`` with a better message if ``xlrd`` is not installed. (:issue:`17613`)
119120

120121

121122
.. _whatsnew_0210.api_breaking:
@@ -134,7 +135,7 @@ We have updated our minimum supported versions of dependencies (:issue:`15206`,
134135

135136
+--------------+-----------------+----------+
136137
| Package | Minimum Version | Required |
137-
+======================+=========+==========+
138+
+==============+=================+==========+
138139
| Numpy | 1.9.0 | X |
139140
+--------------+-----------------+----------+
140141
| Matplotlib | 1.4.3 | |
@@ -240,54 +241,53 @@ New Behaviour:
240241
Dtype Conversions
241242
^^^^^^^^^^^^^^^^^
242243

243-
- Previously assignments, ``.where()`` and ``.fillna()`` with a ``bool`` assignment, would coerce to
244-
same the type (e.g. int / float), or raise for datetimelikes. These will now preseve the bools with ``object`` dtypes. (:issue:`16821`).
244+
Previously assignments, ``.where()`` and ``.fillna()`` with a ``bool`` assignment, would coerce to same the type (e.g. int / float), or raise for datetimelikes. These will now preseve the bools with ``object`` dtypes. (:issue:`16821`).
245245

246-
.. ipython:: python
246+
.. ipython:: python
247247

248-
s = Series([1, 2, 3])
248+
s = Series([1, 2, 3])
249249

250-
.. code-block:: python
250+
.. code-block:: python
251251

252-
In [5]: s[1] = True
252+
In [5]: s[1] = True
253253

254-
In [6]: s
255-
Out[6]:
256-
0 1
257-
1 1
258-
2 3
259-
dtype: int64
254+
In [6]: s
255+
Out[6]:
256+
0 1
257+
1 1
258+
2 3
259+
dtype: int64
260260

261-
New Behavior
261+
New Behavior
262262

263-
.. ipython:: python
263+
.. ipython:: python
264264

265-
s[1] = True
266-
s
265+
s[1] = True
266+
s
267267

268-
- Previously, as assignment to a datetimelike with a non-datetimelike would coerce the
269-
non-datetime-like item being assigned (:issue:`14145`).
268+
Previously, as assignment to a datetimelike with a non-datetimelike would coerce the
269+
non-datetime-like item being assigned (:issue:`14145`).
270270

271-
.. ipython:: python
271+
.. ipython:: python
272272

273-
s = pd.Series([pd.Timestamp('2011-01-01'), pd.Timestamp('2012-01-01')])
273+
s = pd.Series([pd.Timestamp('2011-01-01'), pd.Timestamp('2012-01-01')])
274274

275-
.. code-block:: python
275+
.. code-block:: python
276276

277-
In [1]: s[1] = 1
277+
In [1]: s[1] = 1
278278

279-
In [2]: s
280-
Out[2]:
281-
0 2011-01-01 00:00:00.000000000
282-
1 1970-01-01 00:00:00.000000001
283-
dtype: datetime64[ns]
279+
In [2]: s
280+
Out[2]:
281+
0 2011-01-01 00:00:00.000000000
282+
1 1970-01-01 00:00:00.000000001
283+
dtype: datetime64[ns]
284284

285-
These now coerce to ``object`` dtype.
285+
These now coerce to ``object`` dtype.
286286

287-
.. ipython:: python
287+
.. ipython:: python
288288

289-
s[1] = 1
290-
s
289+
s[1] = 1
290+
s
291291

292292
- Inconsistent behavior in ``.where()`` with datetimelikes which would raise rather than coerce to ``object`` (:issue:`16402`)
293293
- Bug in assignment against ``int64`` data with ``np.ndarray`` with ``float64`` dtype may keep ``int64`` dtype (:issue:`14001`)
@@ -337,26 +337,26 @@ UTC Localization with Series
337337

338338
Previously, :func:`to_datetime` did not localize datetime ``Series`` data when ``utc=True`` was passed. Now, :func:`to_datetime` will correctly localize ``Series`` with a ``datetime64[ns, UTC]`` dtype to be consistent with how list-like and ``Index`` data are handled. (:issue:`6415`).
339339

340-
Previous Behavior
340+
Previous Behavior
341341

342-
.. ipython:: python
342+
.. ipython:: python
343343

344-
s = Series(['20130101 00:00:00'] * 3)
344+
s = Series(['20130101 00:00:00'] * 3)
345345

346-
.. code-block:: ipython
346+
.. code-block:: ipython
347347

348-
In [12]: pd.to_datetime(s, utc=True)
349-
Out[12]:
350-
0 2013-01-01
351-
1 2013-01-01
352-
2 2013-01-01
353-
dtype: datetime64[ns]
348+
In [12]: pd.to_datetime(s, utc=True)
349+
Out[12]:
350+
0 2013-01-01
351+
1 2013-01-01
352+
2 2013-01-01
353+
dtype: datetime64[ns]
354354

355-
New Behavior
355+
New Behavior
356356

357-
.. ipython:: python
357+
.. ipython:: python
358358

359-
pd.to_datetime(s, utc=True)
359+
pd.to_datetime(s, utc=True)
360360

361361
Additionally, DataFrames with datetime columns that were parsed by :func:`read_sql_table` and :func:`read_sql_query` will also be localized to UTC only if the original SQL columns were timezone aware datetime columns.
362362

@@ -409,9 +409,9 @@ Previous Behavior:
409409

410410
New Behavior:
411411

412-
.. ipython:: python
412+
.. ipython:: python
413413

414-
pd.interval_range(start=0, end=4)
414+
pd.interval_range(start=0, end=4)
415415

416416
.. _whatsnew_0210.api:
417417

@@ -473,6 +473,15 @@ Performance Improvements
473473
- Improved performance of :meth:`Categorical.set_categories` by not materializing the values (:issue:`17508`)
474474
- :attr:`Timestamp.microsecond` no longer re-computes on attribute access (:issue:`17331`)
475475
- Improved performance of the :class:`CategoricalIndex` for data that is already categorical dtype (:issue:`17513`)
476+
- Improved performance of :meth:`RangeIndex.min` and :meth:`RangeIndex.max` by using ``RangeIndex`` properties to perform the computations (:issue:`17607`)
477+
478+
.. _whatsnew_0210.docs:
479+
480+
Documentation Changes
481+
~~~~~~~~~~~~~~~~~~~~~
482+
483+
- Several ``NaT`` method docstrings (e.g. :func:`NaT.ctime`) were incorrect (:issue:`17327`)
484+
- The documentation has had references to versions < v0.17 removed and cleaned up (:issue:`17442`, :issue:`17442`, :issue:`17404` & :issue:`17504`)
476485

477486
.. _whatsnew_0210.bug_fixes:
478487

@@ -522,12 +531,13 @@ I/O
522531
- Bug in :func:`read_stata` where the index was not set (:issue:`16342`)
523532
- Bug in :func:`read_html` where import check fails when run in multiple threads (:issue:`16928`)
524533
- Bug in :func:`read_csv` where automatic delimiter detection caused a ``TypeError`` to be thrown when a bad line was encountered rather than the correct error message (:issue:`13374`)
534+
- Bug in ``DataFrame.to_html()`` with ``notebook=True`` where DataFrames with named indices or non-MultiIndex indices had undesired horizontal or vertical alignment for column or row labels, respectively (:issue:`16792`)
525535

526536
Plotting
527537
^^^^^^^^
528538
- Bug in plotting methods using ``secondary_y`` and ``fontsize`` not setting secondary axis font size (:issue:`12565`)
529539
- Bug when plotting ``timedelta`` and ``datetime`` dtypes on y-axis (:issue:`16953`)
530-
- Line plots no longer assume monotonic x data when calculating xlims, they show the entire lines now even for unsorted x data. (:issue:`11310`)(:issue:`11471`)
540+
- Line plots no longer assume monotonic x data when calculating xlims, they show the entire lines now even for unsorted x data. (:issue:`11310`, :issue:`11471`)
531541
- With matplotlib 2.0.0 and above, calculation of x limits for line plots is left to matplotlib, so that its new default settings are applied. (:issue:`15495`)
532542
- Bug in ``Series.plot.bar`` or ``DataFramee.plot.bar`` with ``y`` not respecting user-passed ``color`` (:issue:`16822`)
533543

@@ -572,10 +582,8 @@ Numeric
572582
Categorical
573583
^^^^^^^^^^^
574584
- Bug in :func:`Series.isin` when called with a categorical (:issue`16639`)
575-
- Bug in the categorical constructor with empty values and categories causing
576-
the ``.categories`` to be an empty ``Float64Index`` rather than an empty
577-
``Index`` with object dtype (:issue:`17248`)
578-
- Bug in categorical operations with :ref:`Series.cat <categorical.cat>' not preserving the original Series' name (:issue:`17509`)
585+
- Bug in the categorical constructor with empty values and categories causing the ``.categories`` to be an empty ``Float64Index`` rather than an empty ``Index`` with object dtype (:issue:`17248`)
586+
- Bug in categorical operations with :ref:`Series.cat <categorical.cat>' not preserving the original Series' name (:issue:`17509`)
579587

580588
PyPy
581589
^^^^
@@ -590,5 +598,3 @@ PyPy
590598
Other
591599
^^^^^
592600
- Bug in :func:`eval` where the ``inplace`` parameter was being incorrectly handled (:issue:`16732`)
593-
- Several ``NaT`` method docstrings (e.g. :func:`NaT.ctime`) were incorrect (:issue:`17327`)
594-
- The documentation has had references to versions < v0.17 removed and cleaned up (:issue:`17442`, :issue:`17442`, :issue:`17404` & :issue:`17504`)

pandas/_libs/lib.pyx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1907,5 +1907,4 @@ cdef class BlockPlacement:
19071907

19081908

19091909
include "reduce.pyx"
1910-
include "properties.pyx"
19111910
include "inference.pyx"

pandas/_libs/src/properties.pyx renamed to pandas/_libs/properties.pyx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
2+
from cython cimport Py_ssize_t
3+
14
from cpython cimport (
2-
PyDict_Contains, PyDict_GetItem, PyDict_GetItem, PyDict_SetItem)
5+
PyDict_Contains, PyDict_GetItem, PyDict_SetItem)
36

47

58
cdef class cache_readonly(object):

pandas/_libs/tslib.pyx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,18 +1158,13 @@ cdef class _Timestamp(datetime):
11581158
11591159
If warn=True, issue a warning if nanoseconds is nonzero.
11601160
"""
1161-
cdef:
1162-
pandas_datetimestruct dts
1163-
_TSObject ts
1164-
11651161
if self.nanosecond != 0 and warn:
11661162
warnings.warn("Discarding nonzero nanoseconds in conversion",
11671163
UserWarning, stacklevel=2)
1168-
ts = convert_to_tsobject(self, self.tzinfo, None, 0, 0)
1169-
dts = ts.dts
1170-
return datetime(dts.year, dts.month, dts.day,
1171-
dts.hour, dts.min, dts.sec,
1172-
dts.us, ts.tzinfo)
1164+
1165+
return datetime(self.year, self.month, self.day,
1166+
self.hour, self.minute, self.second,
1167+
self.microsecond, self.tzinfo)
11731168

11741169
cpdef to_datetime64(self):
11751170
""" Returns a numpy.datetime64 object with 'ns' precision """

pandas/core/generic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import numpy as np
1010
import pandas as pd
1111

12-
from pandas._libs import tslib, lib
12+
from pandas._libs import tslib, lib, properties
1313
from pandas.core.dtypes.common import (
1414
_ensure_int64,
1515
_ensure_object,
@@ -258,7 +258,7 @@ def _setup_axes(cls, axes, info_axis=None, stat_axis=None, aliases=None,
258258
if build_axes:
259259

260260
def set_axis(a, i):
261-
setattr(cls, a, lib.AxisProperty(i))
261+
setattr(cls, a, properties.AxisProperty(i))
262262
cls._internal_names_set.add(a)
263263

264264
if axes_are_reversed:

pandas/core/indexes/range.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,24 @@ def copy(self, name=None, deep=False, dtype=None, **kwargs):
269269
return RangeIndex(name=name, fastpath=True,
270270
**dict(self._get_data_as_items()))
271271

272+
def _minmax(self, meth):
273+
no_steps = len(self) - 1
274+
if no_steps == -1:
275+
return np.nan
276+
elif ((meth == 'min' and self._step > 0) or
277+
(meth == 'max' and self._step < 0)):
278+
return self._start
279+
280+
return self._start + self._step * no_steps
281+
282+
def min(self):
283+
"""The minimum value of the RangeIndex"""
284+
return self._minmax('min')
285+
286+
def max(self):
287+
"""The maximum value of the RangeIndex"""
288+
return self._minmax('max')
289+
272290
def argsort(self, *args, **kwargs):
273291
"""
274292
Returns the indices that would sort the index and its

pandas/io/excel.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,17 @@ class ExcelFile(object):
239239

240240
def __init__(self, io, **kwds):
241241

242-
import xlrd # throw an ImportError if we need to
242+
err_msg = "Install xlrd >= 0.9.0 for Excel support"
243243

244-
ver = tuple(map(int, xlrd.__VERSION__.split(".")[:2]))
245-
if ver < (0, 9): # pragma: no cover
246-
raise ImportError("pandas requires xlrd >= 0.9.0 for excel "
247-
"support, current version " + xlrd.__VERSION__)
244+
try:
245+
import xlrd
246+
except ImportError:
247+
raise ImportError(err_msg)
248+
else:
249+
ver = tuple(map(int, xlrd.__VERSION__.split(".")[:2]))
250+
if ver < (0, 9): # pragma: no cover
251+
raise ImportError(err_msg +
252+
". Current version " + xlrd.__VERSION__)
248253

249254
# could be a str, ExcelFile, Book, etc.
250255
self.io = io

0 commit comments

Comments
 (0)