2323import numpy as np
2424import numpy .ma as ma
2525
26- from pandas .types .cast import (_maybe_upcast , _infer_dtype_from_scalar ,
27- _possibly_cast_to_datetime ,
28- _possibly_infer_to_datetimelike ,
29- _possibly_convert_platform ,
30- _possibly_downcast_to_dtype ,
31- _invalidate_string_dtypes ,
32- _coerce_to_dtypes ,
33- _maybe_upcast_putmask ,
34- _find_common_type )
26+ from pandas .types .cast import (maybe_upcast , infer_dtype_from_scalar ,
27+ maybe_cast_to_datetime ,
28+ maybe_infer_to_datetimelike ,
29+ maybe_convert_platform ,
30+ maybe_downcast_to_dtype ,
31+ invalidate_string_dtypes ,
32+ coerce_to_dtypes ,
33+ maybe_upcast_putmask ,
34+ find_common_type )
3535from pandas .types .common import (is_categorical_dtype ,
3636 is_object_dtype ,
3737 is_extension_type ,
@@ -275,7 +275,7 @@ def __init__(self, data=None, index=None, columns=None, dtype=None,
275275 else :
276276 mask = ma .getmaskarray (data )
277277 if mask .any ():
278- data , fill_value = _maybe_upcast (data , copy = True )
278+ data , fill_value = maybe_upcast (data , copy = True )
279279 data [mask ] = fill_value
280280 else :
281281 data = data .copy ()
@@ -335,7 +335,7 @@ def __init__(self, data=None, index=None, columns=None, dtype=None,
335335 if isinstance (data , compat .string_types ) and dtype is None :
336336 dtype = np .object_
337337 if dtype is None :
338- dtype , data = _infer_dtype_from_scalar (data )
338+ dtype , data = infer_dtype_from_scalar (data )
339339
340340 values = np .empty ((len (index ), len (columns )), dtype = dtype )
341341 values .fill (data )
@@ -469,7 +469,7 @@ def _get_axes(N, K, index=index, columns=columns):
469469 # on the entire block; this is to convert if we have datetimelike's
470470 # embedded in an object type
471471 if dtype is None and is_object_dtype (values ):
472- values = _possibly_infer_to_datetimelike (values )
472+ values = maybe_infer_to_datetimelike (values )
473473
474474 return create_block_manager_from_blocks ([values ], [columns , index ])
475475
@@ -2359,7 +2359,7 @@ def select_dtypes(self, include=None, exclude=None):
23592359 include , exclude = map (
23602360 lambda x : frozenset (map (_get_dtype_from_object , x )), selection )
23612361 for dtypes in (include , exclude ):
2362- _invalidate_string_dtypes (dtypes )
2362+ invalidate_string_dtypes (dtypes )
23632363
23642364 # can't both include AND exclude!
23652365 if not include .isdisjoint (exclude ):
@@ -2659,7 +2659,7 @@ def reindexer(value):
26592659 value = _sanitize_index (value , self .index , copy = False )
26602660 if not isinstance (value , (np .ndarray , Index )):
26612661 if isinstance (value , list ) and len (value ) > 0 :
2662- value = _possibly_convert_platform (value )
2662+ value = maybe_convert_platform (value )
26632663 else :
26642664 value = com ._asarray_tuplesafe (value )
26652665 elif value .ndim == 2 :
@@ -2671,13 +2671,13 @@ def reindexer(value):
26712671
26722672 # possibly infer to datetimelike
26732673 if is_object_dtype (value .dtype ):
2674- value = _possibly_infer_to_datetimelike (value )
2674+ value = maybe_infer_to_datetimelike (value )
26752675
26762676 else :
26772677 # upcast the scalar
2678- dtype , value = _infer_dtype_from_scalar (value )
2678+ dtype , value = infer_dtype_from_scalar (value )
26792679 value = np .repeat (value , len (self .index )).astype (dtype )
2680- value = _possibly_cast_to_datetime (value , dtype )
2680+ value = maybe_cast_to_datetime (value , dtype )
26812681
26822682 # return internal types directly
26832683 if is_extension_type (value ):
@@ -3000,8 +3000,8 @@ def _maybe_casted_values(index, labels=None):
30003000 else :
30013001 values = values .take (labels )
30023002 if mask .any ():
3003- values , changed = _maybe_upcast_putmask ( values , mask ,
3004- np .nan )
3003+ values , changed = maybe_upcast_putmask (
3004+ values , mask , np .nan )
30053005 return values
30063006
30073007 new_index = _default_index (len (new_obj ))
@@ -3722,7 +3722,7 @@ def combine(self, other, func, fill_value=None, overwrite=True):
37223722 # if we have different dtypes, possibily promote
37233723 new_dtype = this_dtype
37243724 if not is_dtype_equal (this_dtype , other_dtype ):
3725- new_dtype = _find_common_type ([this_dtype , other_dtype ])
3725+ new_dtype = find_common_type ([this_dtype , other_dtype ])
37263726 if not is_dtype_equal (this_dtype , new_dtype ):
37273727 series = series .astype (new_dtype )
37283728 if not is_dtype_equal (other_dtype , new_dtype ):
@@ -3743,13 +3743,13 @@ def combine(self, other, func, fill_value=None, overwrite=True):
37433743 # try to downcast back to the original dtype
37443744 if needs_i8_conversion_i :
37453745 # ToDo: This conversion should be handled in
3746- # _possibly_cast_to_datetime but the change affects lot...
3746+ # _maybe_cast_to_datetime but the change affects lot...
37473747 if is_datetime64tz_dtype (new_dtype ):
37483748 arr = DatetimeIndex ._simple_new (arr , tz = new_dtype .tz )
37493749 else :
3750- arr = _possibly_cast_to_datetime (arr , new_dtype )
3750+ arr = maybe_cast_to_datetime (arr , new_dtype )
37513751 else :
3752- arr = _possibly_downcast_to_dtype (arr , this_dtype )
3752+ arr = maybe_downcast_to_dtype (arr , this_dtype )
37533753
37543754 result [col ] = arr
37553755
@@ -5003,7 +5003,7 @@ def f(x):
50035003
50045004 # try to coerce to the original dtypes item by item if we can
50055005 if axis == 0 :
5006- result = _coerce_to_dtypes (result , self .dtypes )
5006+ result = coerce_to_dtypes (result , self .dtypes )
50075007
50085008 return Series (result , index = labels )
50095009
@@ -5505,7 +5505,7 @@ def _prep_ndarray(values, copy=True):
55055505 return np .empty ((0 , 0 ), dtype = object )
55065506
55075507 def convert (v ):
5508- return _possibly_convert_platform (v )
5508+ return maybe_convert_platform (v )
55095509
55105510 # we could have a 1-dim or 2-dim list here
55115511 # this is equiv of np.asarray, but does object conversion
@@ -5601,7 +5601,7 @@ def _masked_rec_array_to_mgr(data, index, columns, dtype, copy):
56015601 for fv , arr , col in zip (fill_value , arrays , arr_columns ):
56025602 mask = ma .getmaskarray (data [col ])
56035603 if mask .any ():
5604- arr , fv = _maybe_upcast (arr , fill_value = fv , copy = True )
5604+ arr , fv = maybe_upcast (arr , fill_value = fv , copy = True )
56055605 arr [mask ] = fv
56065606 new_arrays .append (arr )
56075607
@@ -5699,7 +5699,7 @@ def _convert_object_array(content, columns, coerce_float=False, dtype=None):
56995699 def convert (arr ):
57005700 if dtype != object and dtype != np .object :
57015701 arr = lib .maybe_convert_objects (arr , try_float = coerce_float )
5702- arr = _possibly_cast_to_datetime (arr , dtype )
5702+ arr = maybe_cast_to_datetime (arr , dtype )
57035703 return arr
57045704
57055705 arrays = [convert (arr ) for arr in content ]
0 commit comments