20
20
import warnings
21
21
from textwrap import dedent
22
22
23
- from numpy import nan as NA
24
23
import numpy as np
25
24
import numpy .ma as ma
26
25
@@ -436,7 +435,7 @@ def _init_dict(self, data, index, columns, dtype=None):
436
435
else :
437
436
v = np .empty (len (index ), dtype = dtype )
438
437
439
- v .fill (NA )
438
+ v .fill (np . nan )
440
439
else :
441
440
v = data [k ]
442
441
data_names .append (k )
@@ -1437,8 +1436,8 @@ def to_csv(self, path_or_buf=None, sep=",", na_rep='', float_format=None,
1437
1436
columns : sequence, optional
1438
1437
Columns to write
1439
1438
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
1442
1441
index : boolean, default True
1443
1442
Write row names (index)
1444
1443
index_label : string or sequence, or False, default None
@@ -1598,8 +1597,9 @@ def to_feather(self, fname):
1598
1597
from pandas .io .feather_format import to_feather
1599
1598
to_feather (self , fname )
1600
1599
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' )
1603
1603
@Appender (fmt .docstring_to_string , indents = 1 )
1604
1604
def to_string (self , buf = None , columns = None , col_space = None , header = True ,
1605
1605
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,
2781
2781
2782
2782
return frame
2783
2783
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 ,
2785
2785
limit = None , tolerance = None ):
2786
2786
new_index , indexer = self .index .reindex (new_index , method = method ,
2787
2787
level = level , limit = limit ,
@@ -2790,8 +2790,8 @@ def _reindex_index(self, new_index, method, copy, level, fill_value=NA,
2790
2790
copy = copy , fill_value = fill_value ,
2791
2791
allow_dups = False )
2792
2792
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 ):
2795
2795
new_columns , indexer = self .columns .reindex (new_columns , method = method ,
2796
2796
level = level , limit = limit ,
2797
2797
tolerance = tolerance )
@@ -3770,7 +3770,7 @@ def _combine_series(self, other, func, fill_value=None, axis=None,
3770
3770
def _combine_series_infer (self , other , func , level = None ,
3771
3771
fill_value = None , try_cast = True ):
3772
3772
if len (other ) == 0 :
3773
- return self * NA
3773
+ return self * np . nan
3774
3774
3775
3775
if len (self ) == 0 :
3776
3776
# Ambiguous case, use _series so works with DataFrame
@@ -3924,7 +3924,7 @@ def combine(self, other, func, fill_value=None, overwrite=True):
3924
3924
3925
3925
if do_fill :
3926
3926
arr = _ensure_float (arr )
3927
- arr [this_mask & other_mask ] = NA
3927
+ arr [this_mask & other_mask ] = np . nan
3928
3928
3929
3929
# try to downcast back to the original dtype
3930
3930
if needs_i8_conversion_i :
@@ -4543,7 +4543,7 @@ def _apply_empty_result(self, func, axis, reduce, *args, **kwds):
4543
4543
pass
4544
4544
4545
4545
if reduce :
4546
- return Series (NA , index = self ._get_agg_axis (axis ))
4546
+ return Series (np . nan , index = self ._get_agg_axis (axis ))
4547
4547
else :
4548
4548
return self .copy ()
4549
4549
@@ -5161,7 +5161,7 @@ def corr(self, method='pearson', min_periods=1):
5161
5161
5162
5162
valid = mask [i ] & mask [j ]
5163
5163
if valid .sum () < min_periods :
5164
- c = NA
5164
+ c = np . nan
5165
5165
elif i == j :
5166
5166
c = 1.
5167
5167
elif not valid .all ():
@@ -5485,7 +5485,7 @@ def idxmin(self, axis=0, skipna=True):
5485
5485
axis = self ._get_axis_number (axis )
5486
5486
indices = nanops .nanargmin (self .values , axis = axis , skipna = skipna )
5487
5487
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 ]
5489
5489
return Series (result , index = self ._get_agg_axis (axis ))
5490
5490
5491
5491
def idxmax (self , axis = 0 , skipna = True ):
@@ -5516,7 +5516,7 @@ def idxmax(self, axis=0, skipna=True):
5516
5516
axis = self ._get_axis_number (axis )
5517
5517
indices = nanops .nanargmax (self .values , axis = axis , skipna = skipna )
5518
5518
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 ]
5520
5520
return Series (result , index = self ._get_agg_axis (axis ))
5521
5521
5522
5522
def _get_agg_axis (self , axis_num ):
@@ -5754,9 +5754,8 @@ def isin(self, values):
5754
5754
2 True True
5755
5755
"""
5756
5756
if isinstance (values , dict ):
5757
- from collections import defaultdict
5758
5757
from pandas .core .reshape .concat import concat
5759
- values = defaultdict (list , values )
5758
+ values = collections . defaultdict (list , values )
5760
5759
return concat ((self .iloc [:, [i ]].isin (values [col ])
5761
5760
for i , col in enumerate (self .columns )), axis = 1 )
5762
5761
elif isinstance (values , Series ):
@@ -6119,7 +6118,7 @@ def _homogenize(data, index, dtype=None):
6119
6118
v = _dict_compat (v )
6120
6119
else :
6121
6120
v = dict (v )
6122
- v = lib .fast_multiget (v , oindex .values , default = NA )
6121
+ v = lib .fast_multiget (v , oindex .values , default = np . nan )
6123
6122
v = _sanitize_array (v , index , dtype = dtype , copy = False ,
6124
6123
raise_cast_failure = False )
6125
6124
0 commit comments