Skip to content

Commit 1ef3a6c

Browse files
committed
Merge branch 'master' of https://github.com/pandas-dev/pandas into div_zero2
2 parents 78de1a4 + f483321 commit 1ef3a6c

32 files changed

+369
-293
lines changed

asv_bench/benchmarks/replace.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ class Convert(object):
4444

4545
goal_time = 0.5
4646
params = (['DataFrame', 'Series'], ['Timestamp', 'Timedelta'])
47-
param_names = ['contructor', 'replace_data']
47+
param_names = ['constructor', 'replace_data']
4848

49-
def setup(self, contructor, replace_data):
49+
def setup(self, constructor, replace_data):
5050
N = 10**3
5151
data = {'Series': pd.Series(np.random.randint(N, size=N)),
5252
'DataFrame': pd.DataFrame({'A': np.random.randint(N, size=N),
5353
'B': np.random.randint(N, size=N)})}
5454
self.to_replace = {i: getattr(pd, replace_data) for i in range(N)}
55-
self.data = data[contructor]
55+
self.data = data[constructor]
5656

57-
def time_replace(self, contructor, replace_data):
57+
def time_replace(self, constructor, replace_data):
5858
self.data.replace(self.to_replace)

asv_bench/benchmarks/rolling.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ class Methods(object):
1212
['int', 'float'],
1313
['median', 'mean', 'max', 'min', 'std', 'count', 'skew', 'kurt',
1414
'sum', 'corr', 'cov'])
15-
param_names = ['contructor', 'window', 'dtype', 'method']
15+
param_names = ['constructor', 'window', 'dtype', 'method']
1616

17-
def setup(self, contructor, window, dtype, method):
17+
def setup(self, constructor, window, dtype, method):
1818
N = 10**5
1919
arr = np.random.random(N).astype(dtype)
20-
self.roll = getattr(pd, contructor)(arr).rolling(window)
20+
self.roll = getattr(pd, constructor)(arr).rolling(window)
2121

22-
def time_rolling(self, contructor, window, dtype, method):
22+
def time_rolling(self, constructor, window, dtype, method):
2323
getattr(self.roll, method)()
2424

2525

@@ -30,12 +30,12 @@ class Quantile(object):
3030
[10, 1000],
3131
['int', 'float'],
3232
[0, 0.5, 1])
33-
param_names = ['contructor', 'window', 'dtype', 'percentile']
33+
param_names = ['constructor', 'window', 'dtype', 'percentile']
3434

35-
def setup(self, contructor, window, dtype, percentile):
35+
def setup(self, constructor, window, dtype, percentile):
3636
N = 10**5
3737
arr = np.random.random(N).astype(dtype)
38-
self.roll = getattr(pd, contructor)(arr).rolling(window)
38+
self.roll = getattr(pd, constructor)(arr).rolling(window)
3939

40-
def time_quantile(self, contructor, window, dtype, percentile):
40+
def time_quantile(self, constructor, window, dtype, percentile):
4141
self.roll.quantile(percentile)

doc/source/api.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -2500,7 +2500,7 @@ Scalar introspection
25002500
Extensions
25012501
----------
25022502

2503-
These are primarily intented for library authors looking to extend pandas
2503+
These are primarily intended for library authors looking to extend pandas
25042504
objects.
25052505

25062506
.. currentmodule:: pandas

doc/source/io.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -2675,7 +2675,7 @@ file, and the ``sheet_name`` indicating which sheet to parse.
26752675
+++++++++++++++++++
26762676

26772677
To facilitate working with multiple sheets from the same file, the ``ExcelFile``
2678-
class can be used to wrap the file and can be be passed into ``read_excel``
2678+
class can be used to wrap the file and can be passed into ``read_excel``
26792679
There will be a performance benefit for reading multiple sheets as the file is
26802680
read into memory only once.
26812681

@@ -4537,7 +4537,7 @@ See the documentation for `pyarrow <http://arrow.apache.org/docs/python/>`__ and
45374537
.. note::
45384538

45394539
These engines are very similar and should read/write nearly identical parquet format files.
4540-
Currently ``pyarrow`` does not support timedelta data, and ``fastparquet`` does not support timezone aware datetimes (they are coerced to UTC).
4540+
Currently ``pyarrow`` does not support timedelta data, ``fastparquet>=0.1.4`` supports timezone aware datetimes.
45414541
These libraries differ by having different underlying dependencies (``fastparquet`` by using ``numba``, while ``pyarrow`` uses a c-library).
45424542

45434543
.. ipython:: python

doc/source/whatsnew/v0.23.0.txt

+6-1
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ Performance Improvements
431431
- Improved performance of ``DatetimeIndex`` and ``Series`` arithmetic operations with Business-Month and Business-Quarter frequencies (:issue:`18489`)
432432
- :func:`Series` / :func:`DataFrame` tab completion limits to 100 values, for better performance. (:issue:`18587`)
433433
- Improved performance of :func:`DataFrame.median` with ``axis=1`` when bottleneck is not installed (:issue:`16468`)
434+
- Improved performance of :func:`MultiIndex.get_loc` for large indexes, at the cost of a reduction in performance for small ones (:issue:`18519`)
434435

435436

436437
.. _whatsnew_0230.docs:
@@ -528,7 +529,11 @@ MultiIndex
528529
- Bug in :func:`MultiIndex.get_level_values` which would return an invalid index on level of ints with missing values (:issue:`17924`)
529530
- Bug in :func:`MultiIndex.remove_unused_levels` which would fill nan values (:issue:`18417`)
530531
- Bug in :func:`MultiIndex.from_tuples`` which would fail to take zipped tuples in python3 (:issue:`18434`)
531-
-
532+
- Bug in :func:`MultiIndex.get_loc`` which would fail to automatically cast values between float and int (:issue:`18818`, :issue:`15994`)
533+
- Bug in :func:`MultiIndex.get_loc`` which would cast boolean to integer labels (:issue:`19086`)
534+
- Bug in :func:`MultiIndex.get_loc`` which would fail to locate keys containing ``NaN`` (:issue:`18485`)
535+
- Bug in :func:`MultiIndex.get_loc`` in large :class:`MultiIndex`, would fail when levels had different dtypes (:issue:`18520`)
536+
532537

533538
I/O
534539
^^^

doc/sphinxext/numpydoc/tests/test_docscrape.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
-------
4343
out : ndarray
4444
The drawn samples, arranged according to `shape`. If the
45-
shape given is (m,n,...), then the shape of `out` is is
45+
shape given is (m,n,...), then the shape of `out` is
4646
(m,n,...,N).
4747
4848
In other words, each entry ``out[i,j,...,:]`` is an N-dimensional
@@ -222,7 +222,7 @@ def test_str():
222222
-------
223223
out : ndarray
224224
The drawn samples, arranged according to `shape`. If the
225-
shape given is (m,n,...), then the shape of `out` is is
225+
shape given is (m,n,...), then the shape of `out` is
226226
(m,n,...,N).
227227
228228
In other words, each entry ``out[i,j,...,:]`` is an N-dimensional
@@ -340,7 +340,7 @@ def test_sphinx_str():
340340
**out** : ndarray
341341
342342
The drawn samples, arranged according to `shape`. If the
343-
shape given is (m,n,...), then the shape of `out` is is
343+
shape given is (m,n,...), then the shape of `out` is
344344
(m,n,...,N).
345345
346346
In other words, each entry ``out[i,j,...,:]`` is an N-dimensional

pandas/_libs/hashtable.pxd

-9
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,6 @@ cdef class PyObjectHashTable(HashTable):
3131
cpdef get_item(self, object val)
3232
cpdef set_item(self, object key, Py_ssize_t val)
3333

34-
cdef class MultiIndexHashTable(HashTable):
35-
cdef:
36-
kh_uint64_t *table
37-
object mi
38-
39-
cpdef get_item(self, object val)
40-
cpdef set_item(self, object key, Py_ssize_t val)
41-
cdef inline void _check_for_collision(self, Py_ssize_t loc, object label)
42-
4334

4435
cdef class StringHashTable(HashTable):
4536
cdef kh_str_t *table

pandas/_libs/hashtable_class_helper.pxi.in

-136
Original file line numberDiff line numberDiff line change
@@ -899,139 +899,3 @@ cdef class PyObjectHashTable(HashTable):
899899
count += 1
900900

901901
return np.asarray(labels)
902-
903-
904-
cdef class MultiIndexHashTable(HashTable):
905-
906-
def __init__(self, size_hint=1):
907-
self.table = kh_init_uint64()
908-
self.mi = None
909-
kh_resize_uint64(self.table, size_hint)
910-
911-
def __dealloc__(self):
912-
if self.table is not NULL:
913-
kh_destroy_uint64(self.table)
914-
self.table = NULL
915-
916-
def __len__(self):
917-
return self.table.size
918-
919-
def sizeof(self, deep=False):
920-
""" return the size of my table in bytes """
921-
return self.table.n_buckets * (sizeof(uint64_t) + # keys
922-
sizeof(size_t) + # vals
923-
sizeof(uint32_t)) # flags
924-
925-
def _check_for_collisions(self, int64_t[:] locs, object mi):
926-
# validate that the locs map to the actual values
927-
# provided in the mi
928-
# we can only check if we *don't* have any missing values
929-
# :<
930-
cdef:
931-
ndarray[int64_t] alocs
932-
933-
alocs = np.asarray(locs)
934-
if (alocs != -1).all():
935-
936-
result = self.mi.take(locs)
937-
if isinstance(mi, tuple):
938-
from pandas import Index
939-
mi = Index([mi])
940-
if not result.equals(mi):
941-
raise AssertionError(
942-
"hash collision\nlocs:\n{}\n"
943-
"result:\n{}\nmi:\n{}".format(alocs, result, mi))
944-
945-
cdef inline void _check_for_collision(self, Py_ssize_t loc, object label):
946-
# validate that the loc maps to the actual value
947-
# version of _check_for_collisions above for single label (tuple)
948-
949-
result = self.mi[loc]
950-
951-
if not all(l == r or (is_null_datetimelike(l)
952-
and is_null_datetimelike(r))
953-
for l, r in zip(result, label)):
954-
raise AssertionError(
955-
"hash collision\nloc:\n{}\n"
956-
"result:\n{}\nmi:\n{}".format(loc, result, label))
957-
958-
def __contains__(self, object key):
959-
try:
960-
self.get_item(key)
961-
return True
962-
except (KeyError, ValueError, TypeError):
963-
return False
964-
965-
cpdef get_item(self, object key):
966-
cdef:
967-
khiter_t k
968-
uint64_t value
969-
int64_t[:] locs
970-
Py_ssize_t loc
971-
972-
value = self.mi._hashed_indexing_key(key)
973-
k = kh_get_uint64(self.table, value)
974-
if k != self.table.n_buckets:
975-
loc = self.table.vals[k]
976-
self._check_for_collision(loc, key)
977-
return loc
978-
else:
979-
raise KeyError(key)
980-
981-
cpdef set_item(self, object key, Py_ssize_t val):
982-
raise NotImplementedError
983-
984-
@cython.boundscheck(False)
985-
def map_locations(self, object mi):
986-
cdef:
987-
Py_ssize_t i, n
988-
ndarray[uint64_t] values
989-
uint64_t val
990-
int ret = 0
991-
khiter_t k
992-
993-
self.mi = mi
994-
n = len(mi)
995-
values = mi._hashed_values
996-
997-
with nogil:
998-
for i in range(n):
999-
val = values[i]
1000-
k = kh_put_uint64(self.table, val, &ret)
1001-
self.table.vals[k] = i
1002-
1003-
@cython.boundscheck(False)
1004-
def lookup(self, object mi):
1005-
# look up with a target mi
1006-
cdef:
1007-
Py_ssize_t i, n
1008-
ndarray[uint64_t] values
1009-
int ret = 0
1010-
uint64_t val
1011-
khiter_t k
1012-
int64_t[:] locs
1013-
1014-
n = len(mi)
1015-
values = mi._hashed_values
1016-
1017-
locs = np.empty(n, dtype=np.int64)
1018-
1019-
with nogil:
1020-
for i in range(n):
1021-
val = values[i]
1022-
k = kh_get_uint64(self.table, val)
1023-
if k != self.table.n_buckets:
1024-
locs[i] = self.table.vals[k]
1025-
else:
1026-
locs[i] = -1
1027-
1028-
self._check_for_collisions(locs, mi)
1029-
return np.asarray(locs)
1030-
1031-
def unique(self, object mi):
1032-
raise NotImplementedError
1033-
1034-
def get_labels(self, object mi, ObjectVector uniques,
1035-
Py_ssize_t count_prior, int64_t na_sentinel,
1036-
bint check_null=True):
1037-
raise NotImplementedError

0 commit comments

Comments
 (0)