Skip to content

Commit 78de1a4

Browse files
committed
Merge branch 'master' of https://github.com/pandas-dev/pandas into div_zero2
2 parents 0277d9f + 24d9509 commit 78de1a4

Some content is hidden

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

61 files changed

+524
-1590
lines changed

ci/requirements-3.6_WIN.run

+1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ numexpr
1212
pytables
1313
matplotlib
1414
blosc
15+
thrift=0.10*
1516
fastparquet
1617
pyarrow

doc/source/developer.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ Libraries can use the decorators
153153
pandas objects. All of these follow a similar convention: you decorate a class, providing the name of attribute to add. The
154154
class's `__init__` method gets the object being decorated. For example:
155155

156-
.. ipython:: python
156+
.. code-block:: python
157157
158158
@pd.api.extensions.register_dataframe_accessor("geo")
159159
class GeoAccessor(object):

doc/source/whatsnew/v0.23.0.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ Timezones
482482
- :func:`Timestamp.replace` will now handle Daylight Savings transitions gracefully (:issue:`18319`)
483483
- Bug in tz-aware :class:`DatetimeIndex` where addition/subtraction with a :class:`TimedeltaIndex` or array with ``dtype='timedelta64[ns]'`` was incorrect (:issue:`17558`)
484484
- Bug in :func:`DatetimeIndex.insert` where inserting ``NaT`` into a timezone-aware index incorrectly raised (:issue:`16357`)
485+
- Bug in the :class:`DataFrame` constructor, where tz-aware Datetimeindex and a given column name will result in an empty ``DataFrame`` (:issue:`19157`)
485486

486487
Offsets
487488
^^^^^^^
@@ -540,6 +541,8 @@ I/O
540541
- Bug in :func:`DataFrame.to_latex()` where pairs of braces meant to serve as invisible placeholders were escaped (:issue:`18667`)
541542
- Bug in :func:`read_json` where large numeric values were causing an ``OverflowError`` (:issue:`18842`)
542543
- Bug in :func:`DataFrame.to_parquet` where an exception was raised if the write destination is S3 (:issue:`19134`)
544+
- :class:`Interval` now supported in :func:`DataFrame.to_excel` for all Excel file types (:issue:`19242`)
545+
- :class:`Timedelta` now supported in :func:`DataFrame.to_excel` for xls file type (:issue:`19242`, :issue:`9155`)
543546
-
544547

545548
Plotting
@@ -563,7 +566,7 @@ Groupby/Resample/Rolling
563566
Sparse
564567
^^^^^^
565568

566-
-
569+
- Bug in which creating a ``SparseDataFrame`` from a dense ``Series`` or an unsupported type raised an uncontrolled exception (:issue:`19374`)
567570
-
568571
-
569572

pandas/_libs/algos.pyx

+10-15
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,34 @@
11
# cython: profile=False
22

3-
cimport numpy as np
4-
import numpy as np
5-
63
cimport cython
74
from cython cimport Py_ssize_t
85

9-
np.import_array()
10-
11-
cdef float64_t FP_ERR = 1e-13
12-
13-
cimport util
14-
156
from libc.stdlib cimport malloc, free
167
from libc.string cimport memmove
8+
from libc.math cimport fabs, sqrt
179

10+
import numpy as np
11+
cimport numpy as cnp
1812
from numpy cimport (ndarray,
1913
NPY_INT64, NPY_UINT64, NPY_INT32, NPY_INT16, NPY_INT8,
2014
NPY_FLOAT32, NPY_FLOAT64,
2115
NPY_OBJECT,
2216
int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t,
2317
uint32_t, uint64_t, float32_t, float64_t,
2418
double_t)
19+
cnp.import_array()
2520

2621

27-
cdef double NaN = <double> np.NaN
28-
cdef double nan = NaN
29-
30-
from libc.math cimport fabs, sqrt
31-
32-
# this is our util.pxd
22+
cimport util
3323
from util cimport numeric, get_nat
3424

3525
import missing
3626

27+
cdef float64_t FP_ERR = 1e-13
28+
29+
cdef double NaN = <double> np.NaN
30+
cdef double nan = NaN
31+
3732
cdef int64_t iNaT = get_nat()
3833

3934
cdef:

pandas/_libs/algos_rank_helper.pxi.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def rank_1d_{{dtype}}(object in_arr, ties_method='average', ascending=True,
5050

5151
ndarray[float64_t] ranks
5252
ndarray[int64_t] argsorted
53-
ndarray[np.uint8_t, cast=True] sorted_mask
53+
ndarray[uint8_t, cast=True] sorted_mask
5454

5555
{{if dtype == 'uint64'}}
5656
{{ctype}} val

pandas/_libs/hashtable.pyx

+19-19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
# cython: profile=False
22

3-
from cpython cimport PyObject, Py_INCREF, PyList_Check, PyTuple_Check
3+
cimport cython
4+
5+
from cpython cimport (PyObject, Py_INCREF, PyList_Check, PyTuple_Check,
6+
PyMem_Malloc, PyMem_Realloc, PyMem_Free,
7+
PyString_Check, PyBytes_Check,
8+
PyUnicode_Check)
9+
10+
from libc.stdlib cimport malloc, free
11+
12+
import numpy as np
13+
cimport numpy as cnp
14+
from numpy cimport ndarray, uint8_t, uint32_t
15+
cnp.import_array()
16+
17+
cdef extern from "numpy/npy_math.h":
18+
double NAN "NPY_NAN"
19+
420

521
from khash cimport (
622
khiter_t,
@@ -23,29 +39,13 @@ from khash cimport (
2339
kh_put_pymap, kh_resize_pymap)
2440

2541

26-
from numpy cimport ndarray, uint8_t, uint32_t
27-
28-
from libc.stdlib cimport malloc, free
29-
from cpython cimport (PyMem_Malloc, PyMem_Realloc, PyMem_Free,
30-
PyString_Check, PyBytes_Check,
31-
PyUnicode_Check)
32-
3342
from util cimport _checknan
3443
cimport util
3544

36-
import numpy as np
37-
nan = np.nan
38-
39-
cdef extern from "numpy/npy_math.h":
40-
double NAN "NPY_NAN"
41-
42-
cimport cython
43-
cimport numpy as cnp
44-
4545
from missing cimport checknull
4646

47-
cnp.import_array()
48-
cnp.import_ufunc()
47+
48+
nan = np.nan
4949

5050
cdef int64_t iNaT = util.get_nat()
5151
_SIZE_HINT_LIMIT = (1 << 20) + 7

pandas/_libs/index.pyx

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
# cython: profile=False
2+
from datetime import datetime, timedelta, date
23

3-
from numpy cimport (ndarray, float64_t, int32_t, int64_t, uint8_t, uint64_t,
4-
NPY_DATETIME, NPY_TIMEDELTA)
54
cimport cython
65

7-
cimport numpy as cnp
6+
from cpython cimport PyTuple_Check, PyList_Check
7+
from cpython.slice cimport PySlice_Check
88

9+
import numpy as np
10+
cimport numpy as cnp
11+
from numpy cimport ndarray, float64_t, int32_t, int64_t, uint8_t, uint64_t
912
cnp.import_array()
10-
cnp.import_ufunc()
1113

12-
cimport util
14+
cdef extern from "numpy/arrayobject.h":
15+
# These can be cimported directly from numpy in cython>=0.27.3
16+
cdef enum NPY_TYPES:
17+
NPY_DATETIME
18+
NPY_TIMEDELTA
1319

14-
import numpy as np
20+
cimport util
1521

1622
from tslibs.conversion cimport maybe_datetimelike_to_i8
1723

@@ -20,10 +26,6 @@ from hashtable cimport HashTable
2026
from pandas._libs import algos, hashtable as _hash
2127
from pandas._libs.tslibs import period as periodlib
2228
from pandas._libs.tslib import Timestamp, Timedelta
23-
from datetime import datetime, timedelta, date
24-
25-
from cpython cimport PyTuple_Check, PyList_Check
26-
from cpython.slice cimport PySlice_Check
2729

2830
cdef int64_t iNaT = util.get_nat()
2931

pandas/_libs/internals.pyx

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ cdef extern from "Python.h":
1010
Py_ssize_t PY_SSIZE_T_MAX
1111

1212
import numpy as np
13-
cimport numpy as np
1413
from numpy cimport int64_t
1514

1615
cdef extern from "compat_helper.h":

pandas/_libs/interval.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cimport numpy as np
1+
cimport numpy as cnp
22
import numpy as np
33

44
cimport util

pandas/_libs/join.pyx

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
# cython: profile=False
22

3-
cimport numpy as np
4-
import numpy as np
5-
63
cimport cython
74
from cython cimport Py_ssize_t
85

9-
np.import_array()
10-
6+
import numpy as np
7+
cimport numpy as cnp
118
from numpy cimport (ndarray,
129
int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t,
1310
uint32_t, uint64_t, float32_t, float64_t)
11+
cnp.import_array()
12+
1413

1514
cdef double NaN = <double> np.NaN
1615
cdef double nan = NaN

pandas/_libs/lib.pyx

+4-6
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,15 @@ cimport cython
55
from cython cimport Py_ssize_t
66

77
import numpy as np
8-
cimport numpy as np
8+
cimport numpy as cnp
99
from numpy cimport (ndarray, PyArray_NDIM, PyArray_GETITEM,
1010
PyArray_ITER_DATA, PyArray_ITER_NEXT, PyArray_IterNew,
1111
flatiter, NPY_OBJECT,
1212
int64_t,
1313
float32_t, float64_t,
1414
uint8_t, uint64_t,
1515
complex128_t)
16-
# initialize numpy
17-
np.import_array()
18-
np.import_ufunc()
16+
cnp.import_array()
1917

2018
from cpython cimport (Py_INCREF, PyTuple_SET_ITEM,
2119
PyList_Check, PyFloat_Check,
@@ -95,7 +93,7 @@ cpdef bint is_scalar(object val):
9593
9694
"""
9795

98-
return (np.PyArray_IsAnyScalar(val)
96+
return (cnp.PyArray_IsAnyScalar(val)
9997
# As of numpy-1.9, PyArray_IsAnyScalar misses bytearrays on Py3.
10098
or PyBytes_Check(val)
10199
# We differ from numpy (as of 1.10), which claims that None is
@@ -710,7 +708,7 @@ def clean_index_list(list obj):
710708

711709
for i in range(n):
712710
v = obj[i]
713-
if not (PyList_Check(v) or np.PyArray_Check(v) or hasattr(v, '_data')):
711+
if not (PyList_Check(v) or util.is_array(v) or hasattr(v, '_data')):
714712
all_arrays = 0
715713
break
716714

pandas/_libs/missing.pyx

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ cimport cython
77
from cython cimport Py_ssize_t
88

99
import numpy as np
10-
cimport numpy as np
10+
cimport numpy as cnp
1111
from numpy cimport ndarray, int64_t, uint8_t
12-
np.import_array()
12+
cnp.import_array()
1313

1414
cimport util
1515

pandas/_libs/reduction.pyx

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ from cpython cimport Py_INCREF
88
from libc.stdlib cimport malloc, free
99

1010
import numpy as np
11-
cimport numpy as np
11+
cimport numpy as cnp
1212
from numpy cimport (ndarray,
1313
int64_t,
1414
PyArray_SETITEM,
1515
PyArray_ITER_NEXT, PyArray_ITER_DATA, PyArray_IterNew,
1616
flatiter)
17-
np.import_array()
17+
cnp.import_array()
1818

1919
cimport util
2020
from lib import maybe_convert_objects

pandas/_libs/reshape.pyx

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
# cython: profile=False
22

3-
cimport numpy as np
4-
import numpy as np
5-
63
cimport cython
74
from cython cimport Py_ssize_t
85

9-
np.import_array()
10-
6+
import numpy as np
7+
cimport numpy as cnp
118
from numpy cimport (ndarray,
129
int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t,
1310
uint32_t, uint64_t, float32_t, float64_t)
11+
cnp.import_array()
12+
1413

1514
cdef double NaN = <double> np.NaN
1615
cdef double nan = NaN

pandas/_libs/skiplist.pyx

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@
88

99
from libc.math cimport log
1010

11+
import numpy as np
12+
cimport numpy as cnp
13+
from numpy cimport double_t
14+
cnp.import_array()
15+
16+
1117
# MSVC does not have log2!
1218

1319
cdef double Log2(double x):
1420
return log(x) / log(2.)
1521

16-
cimport numpy as np
17-
import numpy as np
18-
from numpy cimport double_t
1922

2023
from random import random
2124

22-
# initialize numpy
23-
np.import_array()
24-
2525
# TODO: optimize this, make less messy
2626

2727
cdef class Node:

pandas/_libs/sparse.pyx

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
from numpy cimport (ndarray, uint8_t, int64_t, int32_t, int16_t, int8_t,
2-
float64_t, float32_t)
3-
cimport numpy as np
1+
# -*- coding: utf-8 -*-
2+
import operator
3+
import sys
44

55
cimport cython
66

77
import numpy as np
8-
import operator
9-
import sys
8+
cimport numpy as cnp
9+
from numpy cimport (ndarray, uint8_t, int64_t, int32_t, int16_t, int8_t,
10+
float64_t, float32_t)
11+
cnp.import_array()
12+
1013

1114
from distutils.version import LooseVersion
1215

@@ -15,8 +18,6 @@ _np_version = np.version.short_version
1518
_np_version_under1p10 = LooseVersion(_np_version) < LooseVersion('1.10')
1619
_np_version_under1p11 = LooseVersion(_np_version) < LooseVersion('1.11')
1720

18-
np.import_array()
19-
np.import_ufunc()
2021

2122
# -----------------------------------------------------------------------------
2223
# Preamble stuff

0 commit comments

Comments
 (0)