Skip to content

Commit fcd2f70

Browse files
jorisvandenbosschejreback
authored andcommitted
CLN: move tools.hashing to util.hashing (#16086)
1 parent d528a10 commit fcd2f70

File tree

7 files changed

+22
-18
lines changed

7 files changed

+22
-18
lines changed

asv_bench/benchmarks/algorithms.py

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1+
from importlib import import_module
2+
13
import numpy as np
4+
25
import pandas as pd
36
from pandas.util import testing as tm
47

5-
try:
6-
from pandas.tools.hashing import hash_pandas_object
7-
except ImportError:
8-
pass
9-
8+
for imp in ['pandas.util.hashing', 'pandas.tools.hashing']:
9+
try:
10+
hashing = import_module(imp)
11+
break
12+
except:
13+
pass
1014

1115
class Algorithms(object):
1216
goal_time = 0.2
@@ -108,13 +112,13 @@ def setup(self):
108112
self.df.iloc[10:20] = np.nan
109113

110114
def time_frame(self):
111-
hash_pandas_object(self.df)
115+
hashing.hash_pandas_object(self.df)
112116

113117
def time_series_int(self):
114-
hash_pandas_object(self.df.E)
118+
hashing.hash_pandas_object(self.df.E)
115119

116120
def time_series_string(self):
117-
hash_pandas_object(self.df.B)
121+
hashing.hash_pandas_object(self.df.B)
118122

119123
def time_series_categorical(self):
120-
hash_pandas_object(self.df.C)
124+
hashing.hash_pandas_object(self.df.C)

doc/source/whatsnew/v0.20.0.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ Other Enhancements
533533
- ``pd.merge_asof()`` gained the option ``direction='backward'|'forward'|'nearest'`` (:issue:`14887`)
534534
- ``Series/DataFrame.asfreq()`` have gained a ``fill_value`` parameter, to fill missing values (:issue:`3715`).
535535
- ``Series/DataFrame.resample.asfreq`` have gained a ``fill_value`` parameter, to fill missing values during resampling (:issue:`3715`).
536-
- ``pandas.tools.hashing`` has gained a ``hash_tuples`` routine, and ``hash_pandas_object`` has gained the ability to hash a ``MultiIndex`` (:issue:`15224`)
536+
- ``pandas.util.hashing`` has gained a ``hash_tuples`` routine, and ``hash_pandas_object`` has gained the ability to hash a ``MultiIndex`` (:issue:`15224`)
537537
- ``Series/DataFrame.squeeze()`` have gained the ``axis`` parameter. (:issue:`15339`)
538538
- ``DataFrame.to_excel()`` has a new ``freeze_panes`` parameter to turn on Freeze Panes when exporting to Excel (:issue:`15160`)
539539
- ``pd.read_html()`` will parse multiple header rows, creating a multiindex header. (:issue:`13434`).
@@ -1423,7 +1423,7 @@ If indicated, a deprecation warning will be issued if you reference theses modul
14231423
"pandas.types", "pandas.core.dtypes", ""
14241424
"pandas.io.sas.saslib", "pandas.io.sas.libsas", ""
14251425
"pandas._join", "pandas._libs.join", ""
1426-
"pandas._hash", "pandas.tools.libhash", ""
1426+
"pandas._hash", "pandas.util.libhashing", ""
14271427
"pandas._period", "pandas._libs.period", ""
14281428
"pandas._sparse", "pandas.core.sparse.libsparse", ""
14291429
"pandas._testing", "pandas.util.libtesting", ""
@@ -1619,7 +1619,7 @@ I/O
16191619
- Bug in ``pd.read_csv()`` for the Python engine in which unhelpful error messages were being raised when parsing errors occurred (:issue:`15910`)
16201620
- Bug in ``pd.read_csv()`` in which the ``skipfooter`` parameter was not being properly validated (:issue:`15925`)
16211621
- Bug in ``pd.to_csv()`` in which there was numeric overflow when a timestamp index was being written (:issue:`15982`)
1622-
- Bug in ``pd.tools.hashing.hash_pandas_object()`` in which hashing of categoricals depended on the ordering of categories, instead of just their values. (:issue:`15143`)
1622+
- Bug in ``pd.util.hashing.hash_pandas_object()`` in which hashing of categoricals depended on the ordering of categories, instead of just their values. (:issue:`15143`)
16231623
- Bug in ``.to_json()`` where ``lines=True`` and contents (keys or values) contain escaped characters (:issue:`15096`)
16241624
- Bug in ``.to_json()`` causing single byte ascii characters to be expanded to four byte unicode (:issue:`15344`)
16251625
- Bug in ``.to_json()`` for the C engine where rollover was not correctly handled for case where frac is odd and diff is exactly 0.5 (:issue:`15716`, :issue:`15864`)

pandas/core/indexes/multi.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ def _inferred_type_levels(self):
718718
@cache_readonly
719719
def _hashed_values(self):
720720
""" return a uint64 ndarray of my hashed values """
721-
from pandas.tools.hashing import hash_tuples
721+
from pandas.util.hashing import hash_tuples
722722
return hash_tuples(self)
723723

724724
def _hashed_indexing_key(self, key):
@@ -740,7 +740,7 @@ def _hashed_indexing_key(self, key):
740740
we need to stringify if we have mixed levels
741741
742742
"""
743-
from pandas.tools.hashing import hash_tuples
743+
from pandas.util.hashing import hash_tuples
744744

745745
if not isinstance(key, tuple):
746746
return hash_tuples(key)

pandas/tests/reshape/test_hashing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import pandas as pd
66

77
from pandas import DataFrame, Series, Index, MultiIndex
8-
from pandas.tools.hashing import hash_array, hash_tuples, hash_pandas_object
8+
from pandas.util.hashing import hash_array, hash_tuples, hash_pandas_object
99
import pandas.util.testing as tm
1010

1111

pandas/tools/hashing.py renamed to pandas/util/hashing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import numpy as np
77
from pandas import Series, factorize, Categorical, Index, MultiIndex
8-
from pandas.tools import libhashing as _hash
8+
from pandas.util import libhashing as _hash
99
from pandas._libs.lib import is_bool_array
1010
from pandas.core.dtypes.generic import (
1111
ABCIndexClass,
File renamed without changes.

setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -528,8 +528,8 @@ def pxd(name):
528528
_pxi_dep['sparse'])},
529529
'util.libtesting': {'pyxfile': 'util/testing',
530530
'depends': ['pandas/util/testing.pyx']},
531-
'tools.libhashing': {'pyxfile': 'tools/hashing',
532-
'depends': ['pandas/tools/hashing.pyx']},
531+
'util.libhashing': {'pyxfile': 'util/hashing',
532+
'depends': ['pandas/util/hashing.pyx']},
533533
'io.sas.libsas': {'pyxfile': 'io/sas/sas'},
534534
}
535535

0 commit comments

Comments
 (0)