45
45
maybe_convert_objects ,
46
46
astype_nansafe ,
47
47
find_common_type ,
48
- _maybe_infer_dtype_type )
48
+ maybe_infer_dtype_type )
49
49
from pandas .core .dtypes .missing import (
50
50
isna , notna , array_equivalent ,
51
51
_isna_compat ,
@@ -630,9 +630,9 @@ def convert(self, copy=True, **kwargs):
630
630
def _can_hold_element (self , element ):
631
631
""" require the same dtype as ourselves """
632
632
dtype = self .values .dtype .type
633
- tipo = _maybe_infer_dtype_type (element )
633
+ tipo = maybe_infer_dtype_type (element )
634
634
if tipo :
635
- return issubclass (tipo , dtype )
635
+ return issubclass (tipo . type , dtype )
636
636
return isinstance (element , dtype )
637
637
638
638
def _try_cast_result (self , result , dtype = None ):
@@ -1806,10 +1806,10 @@ class FloatBlock(FloatOrComplexBlock):
1806
1806
_downcast_dtype = 'int64'
1807
1807
1808
1808
def _can_hold_element (self , element ):
1809
- tipo = _maybe_infer_dtype_type (element )
1809
+ tipo = maybe_infer_dtype_type (element )
1810
1810
if tipo :
1811
- return (issubclass (tipo , (np .floating , np .integer )) and
1812
- not issubclass (tipo , (np .datetime64 , np .timedelta64 )))
1811
+ return (issubclass (tipo . type , (np .floating , np .integer )) and
1812
+ not issubclass (tipo . type , (np .datetime64 , np .timedelta64 )))
1813
1813
return (isinstance (element , (float , int , np .floating , np .int_ )) and
1814
1814
not isinstance (element , (bool , np .bool_ , datetime , timedelta ,
1815
1815
np .datetime64 , np .timedelta64 )))
@@ -1855,9 +1855,9 @@ class ComplexBlock(FloatOrComplexBlock):
1855
1855
is_complex = True
1856
1856
1857
1857
def _can_hold_element (self , element ):
1858
- tipo = _maybe_infer_dtype_type (element )
1858
+ tipo = maybe_infer_dtype_type (element )
1859
1859
if tipo :
1860
- return issubclass (tipo ,
1860
+ return issubclass (tipo . type ,
1861
1861
(np .floating , np .integer , np .complexfloating ))
1862
1862
return (isinstance (element ,
1863
1863
(float , int , complex , np .float_ , np .int_ )) and
@@ -1873,11 +1873,12 @@ class IntBlock(NumericBlock):
1873
1873
_can_hold_na = False
1874
1874
1875
1875
def _can_hold_element (self , element ):
1876
- tipo = _maybe_infer_dtype_type (element )
1876
+ tipo = maybe_infer_dtype_type (element )
1877
1877
if tipo :
1878
- return (issubclass (tipo , np .integer ) and
1879
- not issubclass (tipo , (np .datetime64 , np .timedelta64 )) and
1880
- self .dtype .itemsize >= element .dtype .itemsize )
1878
+ return (issubclass (tipo .type , np .integer ) and
1879
+ not issubclass (tipo .type , (np .datetime64 ,
1880
+ np .timedelta64 )) and
1881
+ self .dtype .itemsize >= tipo .itemsize )
1881
1882
return is_integer (element )
1882
1883
1883
1884
def should_store (self , value ):
@@ -1915,9 +1916,9 @@ def _box_func(self):
1915
1916
return lambda x : tslib .Timedelta (x , unit = 'ns' )
1916
1917
1917
1918
def _can_hold_element (self , element ):
1918
- tipo = _maybe_infer_dtype_type (element )
1919
+ tipo = maybe_infer_dtype_type (element )
1919
1920
if tipo :
1920
- return issubclass (tipo , np .timedelta64 )
1921
+ return issubclass (tipo . type , np .timedelta64 )
1921
1922
return isinstance (element , (timedelta , np .timedelta64 ))
1922
1923
1923
1924
def fillna (self , value , ** kwargs ):
@@ -2015,9 +2016,9 @@ class BoolBlock(NumericBlock):
2015
2016
_can_hold_na = False
2016
2017
2017
2018
def _can_hold_element (self , element ):
2018
- tipo = _maybe_infer_dtype_type (element )
2019
+ tipo = maybe_infer_dtype_type (element )
2019
2020
if tipo :
2020
- return issubclass (tipo , np .bool_ )
2021
+ return issubclass (tipo . type , np .bool_ )
2021
2022
return isinstance (element , (bool , np .bool_ ))
2022
2023
2023
2024
def should_store (self , value ):
@@ -2447,7 +2448,7 @@ def _astype(self, dtype, mgr=None, **kwargs):
2447
2448
return super (DatetimeBlock , self )._astype (dtype = dtype , ** kwargs )
2448
2449
2449
2450
def _can_hold_element (self , element ):
2450
- tipo = _maybe_infer_dtype_type (element )
2451
+ tipo = maybe_infer_dtype_type (element )
2451
2452
if tipo :
2452
2453
# TODO: this still uses asarray, instead of dtype.type
2453
2454
element = np .array (element )
0 commit comments