2020import warnings
2121from textwrap import dedent
2222
23- from numpy import nan as NA
2423import numpy as np
2524import numpy .ma as ma
2625
@@ -436,7 +435,7 @@ def _init_dict(self, data, index, columns, dtype=None):
436435 else :
437436 v = np .empty (len (index ), dtype = dtype )
438437
439- v .fill (NA )
438+ v .fill (np . nan )
440439 else :
441440 v = data [k ]
442441 data_names .append (k )
@@ -1437,8 +1436,8 @@ def to_csv(self, path_or_buf=None, sep=",", na_rep='', float_format=None,
14371436 columns : sequence, optional
14381437 Columns to write
14391438 header : boolean or list of string, default True
1440- Write out column names. If a list of string is given it is assumed
1441- to be aliases for the column names
1439+ Write out the column names. If a list of strings is given it is
1440+ assumed to be aliases for the column names
14421441 index : boolean, default True
14431442 Write row names (index)
14441443 index_label : string or sequence, or False, default None
@@ -1598,8 +1597,9 @@ def to_feather(self, fname):
15981597 from pandas .io .feather_format import to_feather
15991598 to_feather (self , fname )
16001599
1601- @Substitution (header = 'Write out column names. If a list of string is given, \
1602- it is assumed to be aliases for the column names' )
1600+ @Substitution (header = 'Write out the column names. If a list of strings '
1601+ 'is given, it is assumed to be aliases for the '
1602+ 'column names' )
16031603 @Appender (fmt .docstring_to_string , indents = 1 )
16041604 def to_string (self , buf = None , columns = None , col_space = None , header = True ,
16051605 index = True , na_rep = 'NaN' , formatters = None , float_format = None ,
@@ -2781,7 +2781,7 @@ def _reindex_axes(self, axes, level, limit, tolerance, method, fill_value,
27812781
27822782 return frame
27832783
2784- def _reindex_index (self , new_index , method , copy , level , fill_value = NA ,
2784+ def _reindex_index (self , new_index , method , copy , level , fill_value = np . nan ,
27852785 limit = None , tolerance = None ):
27862786 new_index , indexer = self .index .reindex (new_index , method = method ,
27872787 level = level , limit = limit ,
@@ -2790,8 +2790,8 @@ def _reindex_index(self, new_index, method, copy, level, fill_value=NA,
27902790 copy = copy , fill_value = fill_value ,
27912791 allow_dups = False )
27922792
2793- def _reindex_columns (self , new_columns , method , copy , level , fill_value = NA ,
2794- limit = None , tolerance = None ):
2793+ def _reindex_columns (self , new_columns , method , copy , level ,
2794+ fill_value = np . nan , limit = None , tolerance = None ):
27952795 new_columns , indexer = self .columns .reindex (new_columns , method = method ,
27962796 level = level , limit = limit ,
27972797 tolerance = tolerance )
@@ -3770,7 +3770,7 @@ def _combine_series(self, other, func, fill_value=None, axis=None,
37703770 def _combine_series_infer (self , other , func , level = None ,
37713771 fill_value = None , try_cast = True ):
37723772 if len (other ) == 0 :
3773- return self * NA
3773+ return self * np . nan
37743774
37753775 if len (self ) == 0 :
37763776 # Ambiguous case, use _series so works with DataFrame
@@ -3924,7 +3924,7 @@ def combine(self, other, func, fill_value=None, overwrite=True):
39243924
39253925 if do_fill :
39263926 arr = _ensure_float (arr )
3927- arr [this_mask & other_mask ] = NA
3927+ arr [this_mask & other_mask ] = np . nan
39283928
39293929 # try to downcast back to the original dtype
39303930 if needs_i8_conversion_i :
@@ -4543,7 +4543,7 @@ def _apply_empty_result(self, func, axis, reduce, *args, **kwds):
45434543 pass
45444544
45454545 if reduce :
4546- return Series (NA , index = self ._get_agg_axis (axis ))
4546+ return Series (np . nan , index = self ._get_agg_axis (axis ))
45474547 else :
45484548 return self .copy ()
45494549
@@ -5161,7 +5161,7 @@ def corr(self, method='pearson', min_periods=1):
51615161
51625162 valid = mask [i ] & mask [j ]
51635163 if valid .sum () < min_periods :
5164- c = NA
5164+ c = np . nan
51655165 elif i == j :
51665166 c = 1.
51675167 elif not valid .all ():
@@ -5485,7 +5485,7 @@ def idxmin(self, axis=0, skipna=True):
54855485 axis = self ._get_axis_number (axis )
54865486 indices = nanops .nanargmin (self .values , axis = axis , skipna = skipna )
54875487 index = self ._get_axis (axis )
5488- result = [index [i ] if i >= 0 else NA for i in indices ]
5488+ result = [index [i ] if i >= 0 else np . nan for i in indices ]
54895489 return Series (result , index = self ._get_agg_axis (axis ))
54905490
54915491 def idxmax (self , axis = 0 , skipna = True ):
@@ -5516,7 +5516,7 @@ def idxmax(self, axis=0, skipna=True):
55165516 axis = self ._get_axis_number (axis )
55175517 indices = nanops .nanargmax (self .values , axis = axis , skipna = skipna )
55185518 index = self ._get_axis (axis )
5519- result = [index [i ] if i >= 0 else NA for i in indices ]
5519+ result = [index [i ] if i >= 0 else np . nan for i in indices ]
55205520 return Series (result , index = self ._get_agg_axis (axis ))
55215521
55225522 def _get_agg_axis (self , axis_num ):
@@ -5754,9 +5754,8 @@ def isin(self, values):
57545754 2 True True
57555755 """
57565756 if isinstance (values , dict ):
5757- from collections import defaultdict
57585757 from pandas .core .reshape .concat import concat
5759- values = defaultdict (list , values )
5758+ values = collections . defaultdict (list , values )
57605759 return concat ((self .iloc [:, [i ]].isin (values [col ])
57615760 for i , col in enumerate (self .columns )), axis = 1 )
57625761 elif isinstance (values , Series ):
@@ -6119,7 +6118,7 @@ def _homogenize(data, index, dtype=None):
61196118 v = _dict_compat (v )
61206119 else :
61216120 v = dict (v )
6122- v = lib .fast_multiget (v , oindex .values , default = NA )
6121+ v = lib .fast_multiget (v , oindex .values , default = np . nan )
61236122 v = _sanitize_array (v , index , dtype = dtype , copy = False ,
61246123 raise_cast_failure = False )
61256124
0 commit comments