Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/pandas-dev/pandas into di…
Browse files Browse the repository at this point in the history
…v_zero2
  • Loading branch information
jbrockmendel committed Jan 28, 2018
2 parents 0277d9f + 24d9509 commit 78de1a4
Show file tree
Hide file tree
Showing 61 changed files with 524 additions and 1,590 deletions.
1 change: 1 addition & 0 deletions ci/requirements-3.6_WIN.run
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ numexpr
pytables
matplotlib
blosc
thrift=0.10*
fastparquet
pyarrow
2 changes: 1 addition & 1 deletion doc/source/developer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ Libraries can use the decorators
pandas objects. All of these follow a similar convention: you decorate a class, providing the name of attribute to add. The
class's `__init__` method gets the object being decorated. For example:

.. ipython:: python
.. code-block:: python
@pd.api.extensions.register_dataframe_accessor("geo")
class GeoAccessor(object):
Expand Down
5 changes: 4 additions & 1 deletion doc/source/whatsnew/v0.23.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ Timezones
- :func:`Timestamp.replace` will now handle Daylight Savings transitions gracefully (:issue:`18319`)
- Bug in tz-aware :class:`DatetimeIndex` where addition/subtraction with a :class:`TimedeltaIndex` or array with ``dtype='timedelta64[ns]'`` was incorrect (:issue:`17558`)
- Bug in :func:`DatetimeIndex.insert` where inserting ``NaT`` into a timezone-aware index incorrectly raised (:issue:`16357`)
- Bug in the :class:`DataFrame` constructor, where tz-aware Datetimeindex and a given column name will result in an empty ``DataFrame`` (:issue:`19157`)

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

Plotting
Expand All @@ -563,7 +566,7 @@ Groupby/Resample/Rolling
Sparse
^^^^^^

-
- Bug in which creating a ``SparseDataFrame`` from a dense ``Series`` or an unsupported type raised an uncontrolled exception (:issue:`19374`)
-
-

Expand Down
25 changes: 10 additions & 15 deletions pandas/_libs/algos.pyx
Original file line number Diff line number Diff line change
@@ -1,39 +1,34 @@
# cython: profile=False

cimport numpy as np
import numpy as np

cimport cython
from cython cimport Py_ssize_t

np.import_array()

cdef float64_t FP_ERR = 1e-13

cimport util

from libc.stdlib cimport malloc, free
from libc.string cimport memmove
from libc.math cimport fabs, sqrt

import numpy as np
cimport numpy as cnp
from numpy cimport (ndarray,
NPY_INT64, NPY_UINT64, NPY_INT32, NPY_INT16, NPY_INT8,
NPY_FLOAT32, NPY_FLOAT64,
NPY_OBJECT,
int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t,
uint32_t, uint64_t, float32_t, float64_t,
double_t)
cnp.import_array()


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

from libc.math cimport fabs, sqrt

# this is our util.pxd
cimport util
from util cimport numeric, get_nat

import missing

cdef float64_t FP_ERR = 1e-13

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

cdef int64_t iNaT = get_nat()

cdef:
Expand Down
2 changes: 1 addition & 1 deletion pandas/_libs/algos_rank_helper.pxi.in
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def rank_1d_{{dtype}}(object in_arr, ties_method='average', ascending=True,

ndarray[float64_t] ranks
ndarray[int64_t] argsorted
ndarray[np.uint8_t, cast=True] sorted_mask
ndarray[uint8_t, cast=True] sorted_mask

{{if dtype == 'uint64'}}
{{ctype}} val
Expand Down
38 changes: 19 additions & 19 deletions pandas/_libs/hashtable.pyx
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
# cython: profile=False

from cpython cimport PyObject, Py_INCREF, PyList_Check, PyTuple_Check
cimport cython

from cpython cimport (PyObject, Py_INCREF, PyList_Check, PyTuple_Check,
PyMem_Malloc, PyMem_Realloc, PyMem_Free,
PyString_Check, PyBytes_Check,
PyUnicode_Check)

from libc.stdlib cimport malloc, free

import numpy as np
cimport numpy as cnp
from numpy cimport ndarray, uint8_t, uint32_t
cnp.import_array()

cdef extern from "numpy/npy_math.h":
double NAN "NPY_NAN"


from khash cimport (
khiter_t,
Expand All @@ -23,29 +39,13 @@ from khash cimport (
kh_put_pymap, kh_resize_pymap)


from numpy cimport ndarray, uint8_t, uint32_t

from libc.stdlib cimport malloc, free
from cpython cimport (PyMem_Malloc, PyMem_Realloc, PyMem_Free,
PyString_Check, PyBytes_Check,
PyUnicode_Check)

from util cimport _checknan
cimport util

import numpy as np
nan = np.nan

cdef extern from "numpy/npy_math.h":
double NAN "NPY_NAN"

cimport cython
cimport numpy as cnp

from missing cimport checknull

cnp.import_array()
cnp.import_ufunc()

nan = np.nan

cdef int64_t iNaT = util.get_nat()
_SIZE_HINT_LIMIT = (1 << 20) + 7
Expand Down
22 changes: 12 additions & 10 deletions pandas/_libs/index.pyx
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
# cython: profile=False
from datetime import datetime, timedelta, date

from numpy cimport (ndarray, float64_t, int32_t, int64_t, uint8_t, uint64_t,
NPY_DATETIME, NPY_TIMEDELTA)
cimport cython

cimport numpy as cnp
from cpython cimport PyTuple_Check, PyList_Check
from cpython.slice cimport PySlice_Check

import numpy as np
cimport numpy as cnp
from numpy cimport ndarray, float64_t, int32_t, int64_t, uint8_t, uint64_t
cnp.import_array()
cnp.import_ufunc()

cimport util
cdef extern from "numpy/arrayobject.h":
# These can be cimported directly from numpy in cython>=0.27.3
cdef enum NPY_TYPES:
NPY_DATETIME
NPY_TIMEDELTA

import numpy as np
cimport util

from tslibs.conversion cimport maybe_datetimelike_to_i8

Expand All @@ -20,10 +26,6 @@ from hashtable cimport HashTable
from pandas._libs import algos, hashtable as _hash
from pandas._libs.tslibs import period as periodlib
from pandas._libs.tslib import Timestamp, Timedelta
from datetime import datetime, timedelta, date

from cpython cimport PyTuple_Check, PyList_Check
from cpython.slice cimport PySlice_Check

cdef int64_t iNaT = util.get_nat()

Expand Down
1 change: 0 additions & 1 deletion pandas/_libs/internals.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ cdef extern from "Python.h":
Py_ssize_t PY_SSIZE_T_MAX

import numpy as np
cimport numpy as np
from numpy cimport int64_t

cdef extern from "compat_helper.h":
Expand Down
2 changes: 1 addition & 1 deletion pandas/_libs/interval.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cimport numpy as np
cimport numpy as cnp
import numpy as np

cimport util
Expand Down
9 changes: 4 additions & 5 deletions pandas/_libs/join.pyx
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# cython: profile=False

cimport numpy as np
import numpy as np

cimport cython
from cython cimport Py_ssize_t

np.import_array()

import numpy as np
cimport numpy as cnp
from numpy cimport (ndarray,
int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t,
uint32_t, uint64_t, float32_t, float64_t)
cnp.import_array()


cdef double NaN = <double> np.NaN
cdef double nan = NaN
Expand Down
10 changes: 4 additions & 6 deletions pandas/_libs/lib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@ cimport cython
from cython cimport Py_ssize_t

import numpy as np
cimport numpy as np
cimport numpy as cnp
from numpy cimport (ndarray, PyArray_NDIM, PyArray_GETITEM,
PyArray_ITER_DATA, PyArray_ITER_NEXT, PyArray_IterNew,
flatiter, NPY_OBJECT,
int64_t,
float32_t, float64_t,
uint8_t, uint64_t,
complex128_t)
# initialize numpy
np.import_array()
np.import_ufunc()
cnp.import_array()

from cpython cimport (Py_INCREF, PyTuple_SET_ITEM,
PyList_Check, PyFloat_Check,
Expand Down Expand Up @@ -95,7 +93,7 @@ cpdef bint is_scalar(object val):
"""

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

for i in range(n):
v = obj[i]
if not (PyList_Check(v) or np.PyArray_Check(v) or hasattr(v, '_data')):
if not (PyList_Check(v) or util.is_array(v) or hasattr(v, '_data')):
all_arrays = 0
break

Expand Down
4 changes: 2 additions & 2 deletions pandas/_libs/missing.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ cimport cython
from cython cimport Py_ssize_t

import numpy as np
cimport numpy as np
cimport numpy as cnp
from numpy cimport ndarray, int64_t, uint8_t
np.import_array()
cnp.import_array()

cimport util

Expand Down
4 changes: 2 additions & 2 deletions pandas/_libs/reduction.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ from cpython cimport Py_INCREF
from libc.stdlib cimport malloc, free

import numpy as np
cimport numpy as np
cimport numpy as cnp
from numpy cimport (ndarray,
int64_t,
PyArray_SETITEM,
PyArray_ITER_NEXT, PyArray_ITER_DATA, PyArray_IterNew,
flatiter)
np.import_array()
cnp.import_array()

cimport util
from lib import maybe_convert_objects
Expand Down
9 changes: 4 additions & 5 deletions pandas/_libs/reshape.pyx
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# cython: profile=False

cimport numpy as np
import numpy as np

cimport cython
from cython cimport Py_ssize_t

np.import_array()

import numpy as np
cimport numpy as cnp
from numpy cimport (ndarray,
int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t,
uint32_t, uint64_t, float32_t, float64_t)
cnp.import_array()


cdef double NaN = <double> np.NaN
cdef double nan = NaN
Expand Down
12 changes: 6 additions & 6 deletions pandas/_libs/skiplist.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@

from libc.math cimport log

import numpy as np
cimport numpy as cnp
from numpy cimport double_t
cnp.import_array()


# MSVC does not have log2!

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

cimport numpy as np
import numpy as np
from numpy cimport double_t

from random import random

# initialize numpy
np.import_array()

# TODO: optimize this, make less messy

cdef class Node:
Expand Down
15 changes: 8 additions & 7 deletions pandas/_libs/sparse.pyx
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
from numpy cimport (ndarray, uint8_t, int64_t, int32_t, int16_t, int8_t,
float64_t, float32_t)
cimport numpy as np
# -*- coding: utf-8 -*-
import operator
import sys

cimport cython

import numpy as np
import operator
import sys
cimport numpy as cnp
from numpy cimport (ndarray, uint8_t, int64_t, int32_t, int16_t, int8_t,
float64_t, float32_t)
cnp.import_array()


from distutils.version import LooseVersion

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

np.import_array()
np.import_ufunc()

# -----------------------------------------------------------------------------
# Preamble stuff
Expand Down
Loading

0 comments on commit 78de1a4

Please sign in to comment.