@@ -795,99 +795,7 @@ def __unicode__(self):
795
795
return "%s(%s, dtype='%s')" % (type (self ).__name__ , prepr , self .dtype )
796
796
797
797
798
- class HashableMixin (object ):
799
- """ provide methods for hashable pandas objects """
800
-
801
- def hash (self , index = True , encoding = 'utf8' , hash_key = None ):
802
- """
803
- Return a data hash of the Index/Series/DataFrame
804
- This is a 1-d Series of unique hashses of all of the elements in that
805
- row, including the index if desired.
806
-
807
- Parameters
808
- ----------
809
- index : boolean, default True
810
- include the index in the hash (if Series/DataFrame)
811
- encoding : string, default 'utf8'
812
- encoding for data & key when strings
813
- hash_key : string, must be 16 bytes length if passed
814
-
815
- Returns
816
- -------
817
- Series of uint64 hash values. The index of the Series
818
- will be the original index (Series/DataFrame),
819
- or the original object if Index
820
-
821
- Examples
822
- --------
823
- >>> pd.Index([1, 2, 3]).hash()
824
- 1 6238072747940578789
825
- 2 15839785061582574730
826
- 3 2185194620014831856
827
- dtype: uint64
828
-
829
- >>> pd.Series([1, 2, 3], index=[2, 3, 4]).hash()
830
- 2 16107259231694759481
831
- 3 12811061657343452814
832
- 4 1341665827200607204
833
- dtype: uint64
834
-
835
- >>> pd.Series([1, 2, 3]).hash(index=False)
836
- 0 6238072747940578789
837
- 1 15839785061582574730
838
- 2 2185194620014831856
839
- dtype: uint64
840
-
841
- >>> pd.DataFrame({'A': [1, 2, 3]}).hash()
842
- 0 267474170112184751
843
- 1 16863939785269199747
844
- 2 3948624847917518682
845
- dtype: uint64
846
-
847
- >>> pd.DataFrame({'A': [1, 2, 3], 'B': ['foo', 'bar', 'baz']}).hash()
848
- 0 11603696091789712533
849
- 1 5345384428795788641
850
- 2 46691607209239364
851
- dtype: uint64
852
-
853
- In [10]: pd.DataFrame({'A': [1, 1, 2], 'B': ['foo', 'bar', 'foo'],
854
- 'C': [1, 2, 3]}).set_index(['A', 'B']).hash()
855
- A B
856
- 1 foo 553964757138028680
857
- bar 13757638258637221887
858
- 2 foo 4843577173406411690
859
- dtype: uint64
860
-
861
- Notes
862
- -----
863
- These functions do not hash attributes attached to the object
864
- e.g. name for Index/Series. Nor do they hash the columns of
865
- a DataFrame.
866
-
867
- Mixed dtypes within a Series (or a column of a DataFrame) will
868
- be stringified, for example.
869
-
870
- >>> Series(['1', 2, 3]).hash()
871
- array([ 8973981985592347666, 16940873351292606887,
872
- 10100427194775696709], dtype=uint64)
873
-
874
- >>> Series(['1', '2', '3']).hash()
875
- array([ 8973981985592347666, 16940873351292606887,
876
- 10100427194775696709], dtype=uint64)
877
-
878
- These have the same data hash, while a pure dtype is different.
879
-
880
- >>> Series([1, 2, 3]).hash()
881
- array([ 267474170112184751, 16863939785269199747,
882
- 3948624847917518682], dtype=uint64)
883
-
884
- """
885
- from pandas .tools .hashing import hash_pandas_object
886
- return hash_pandas_object (self , index = index , encoding = encoding ,
887
- hash_key = hash_key )
888
-
889
-
890
- class IndexOpsMixin (HashableMixin ):
798
+ class IndexOpsMixin (object ):
891
799
""" common ops mixin to support a unified inteface / docs for Series /
892
800
Index
893
801
"""
0 commit comments