23
23
import numpy as np
24
24
import numpy .ma as ma
25
25
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 )
35
35
from pandas .types .common import (is_categorical_dtype ,
36
36
is_object_dtype ,
37
37
is_extension_type ,
@@ -275,7 +275,7 @@ def __init__(self, data=None, index=None, columns=None, dtype=None,
275
275
else :
276
276
mask = ma .getmaskarray (data )
277
277
if mask .any ():
278
- data , fill_value = _maybe_upcast (data , copy = True )
278
+ data , fill_value = maybe_upcast (data , copy = True )
279
279
data [mask ] = fill_value
280
280
else :
281
281
data = data .copy ()
@@ -335,7 +335,7 @@ def __init__(self, data=None, index=None, columns=None, dtype=None,
335
335
if isinstance (data , compat .string_types ) and dtype is None :
336
336
dtype = np .object_
337
337
if dtype is None :
338
- dtype , data = _infer_dtype_from_scalar (data )
338
+ dtype , data = infer_dtype_from_scalar (data )
339
339
340
340
values = np .empty ((len (index ), len (columns )), dtype = dtype )
341
341
values .fill (data )
@@ -469,7 +469,7 @@ def _get_axes(N, K, index=index, columns=columns):
469
469
# on the entire block; this is to convert if we have datetimelike's
470
470
# embedded in an object type
471
471
if dtype is None and is_object_dtype (values ):
472
- values = _possibly_infer_to_datetimelike (values )
472
+ values = maybe_infer_to_datetimelike (values )
473
473
474
474
return create_block_manager_from_blocks ([values ], [columns , index ])
475
475
@@ -2359,7 +2359,7 @@ def select_dtypes(self, include=None, exclude=None):
2359
2359
include , exclude = map (
2360
2360
lambda x : frozenset (map (_get_dtype_from_object , x )), selection )
2361
2361
for dtypes in (include , exclude ):
2362
- _invalidate_string_dtypes (dtypes )
2362
+ invalidate_string_dtypes (dtypes )
2363
2363
2364
2364
# can't both include AND exclude!
2365
2365
if not include .isdisjoint (exclude ):
@@ -2659,7 +2659,7 @@ def reindexer(value):
2659
2659
value = _sanitize_index (value , self .index , copy = False )
2660
2660
if not isinstance (value , (np .ndarray , Index )):
2661
2661
if isinstance (value , list ) and len (value ) > 0 :
2662
- value = _possibly_convert_platform (value )
2662
+ value = maybe_convert_platform (value )
2663
2663
else :
2664
2664
value = com ._asarray_tuplesafe (value )
2665
2665
elif value .ndim == 2 :
@@ -2671,13 +2671,13 @@ def reindexer(value):
2671
2671
2672
2672
# possibly infer to datetimelike
2673
2673
if is_object_dtype (value .dtype ):
2674
- value = _possibly_infer_to_datetimelike (value )
2674
+ value = maybe_infer_to_datetimelike (value )
2675
2675
2676
2676
else :
2677
2677
# upcast the scalar
2678
- dtype , value = _infer_dtype_from_scalar (value )
2678
+ dtype , value = infer_dtype_from_scalar (value )
2679
2679
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 )
2681
2681
2682
2682
# return internal types directly
2683
2683
if is_extension_type (value ):
@@ -3000,8 +3000,8 @@ def _maybe_casted_values(index, labels=None):
3000
3000
else :
3001
3001
values = values .take (labels )
3002
3002
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 )
3005
3005
return values
3006
3006
3007
3007
new_index = _default_index (len (new_obj ))
@@ -3722,7 +3722,7 @@ def combine(self, other, func, fill_value=None, overwrite=True):
3722
3722
# if we have different dtypes, possibily promote
3723
3723
new_dtype = this_dtype
3724
3724
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 ])
3726
3726
if not is_dtype_equal (this_dtype , new_dtype ):
3727
3727
series = series .astype (new_dtype )
3728
3728
if not is_dtype_equal (other_dtype , new_dtype ):
@@ -3743,13 +3743,13 @@ def combine(self, other, func, fill_value=None, overwrite=True):
3743
3743
# try to downcast back to the original dtype
3744
3744
if needs_i8_conversion_i :
3745
3745
# 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...
3747
3747
if is_datetime64tz_dtype (new_dtype ):
3748
3748
arr = DatetimeIndex ._simple_new (arr , tz = new_dtype .tz )
3749
3749
else :
3750
- arr = _possibly_cast_to_datetime (arr , new_dtype )
3750
+ arr = maybe_cast_to_datetime (arr , new_dtype )
3751
3751
else :
3752
- arr = _possibly_downcast_to_dtype (arr , this_dtype )
3752
+ arr = maybe_downcast_to_dtype (arr , this_dtype )
3753
3753
3754
3754
result [col ] = arr
3755
3755
@@ -5003,7 +5003,7 @@ def f(x):
5003
5003
5004
5004
# try to coerce to the original dtypes item by item if we can
5005
5005
if axis == 0 :
5006
- result = _coerce_to_dtypes (result , self .dtypes )
5006
+ result = coerce_to_dtypes (result , self .dtypes )
5007
5007
5008
5008
return Series (result , index = labels )
5009
5009
@@ -5505,7 +5505,7 @@ def _prep_ndarray(values, copy=True):
5505
5505
return np .empty ((0 , 0 ), dtype = object )
5506
5506
5507
5507
def convert (v ):
5508
- return _possibly_convert_platform (v )
5508
+ return maybe_convert_platform (v )
5509
5509
5510
5510
# we could have a 1-dim or 2-dim list here
5511
5511
# 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):
5601
5601
for fv , arr , col in zip (fill_value , arrays , arr_columns ):
5602
5602
mask = ma .getmaskarray (data [col ])
5603
5603
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 )
5605
5605
arr [mask ] = fv
5606
5606
new_arrays .append (arr )
5607
5607
@@ -5699,7 +5699,7 @@ def _convert_object_array(content, columns, coerce_float=False, dtype=None):
5699
5699
def convert (arr ):
5700
5700
if dtype != object and dtype != np .object :
5701
5701
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 )
5703
5703
return arr
5704
5704
5705
5705
arrays = [convert (arr ) for arr in content ]
0 commit comments