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
@@ -1622,8 +1621,9 @@ def to_parquet(self, fname, engine='auto', compression='snappy',
1622
1621
to_parquet (self , fname , engine ,
1623
1622
compression = compression , ** kwargs )
1624
1623
1625
- @Substitution (header = 'Write out column names. If a list of string is given, \
1626
- it is assumed to be aliases for the column names' )
1624
+ @Substitution (header = 'Write out the column names. If a list of strings '
1625
+ 'is given, it is assumed to be aliases for the '
1626
+ 'column names' )
1627
1627
@Appender (fmt .docstring_to_string , indents = 1 )
1628
1628
def to_string (self , buf = None , columns = None , col_space = None , header = True ,
1629
1629
index = True , na_rep = 'NaN' , formatters = None , float_format = None ,
@@ -2805,7 +2805,7 @@ def _reindex_axes(self, axes, level, limit, tolerance, method, fill_value,
2805
2805
2806
2806
return frame
2807
2807
2808
- def _reindex_index (self , new_index , method , copy , level , fill_value = NA ,
2808
+ def _reindex_index (self , new_index , method , copy , level , fill_value = np . nan ,
2809
2809
limit = None , tolerance = None ):
2810
2810
new_index , indexer = self .index .reindex (new_index , method = method ,
2811
2811
level = level , limit = limit ,
@@ -2814,8 +2814,8 @@ def _reindex_index(self, new_index, method, copy, level, fill_value=NA,
2814
2814
copy = copy , fill_value = fill_value ,
2815
2815
allow_dups = False )
2816
2816
2817
- def _reindex_columns (self , new_columns , method , copy , level , fill_value = NA ,
2818
- limit = None , tolerance = None ):
2817
+ def _reindex_columns (self , new_columns , method , copy , level ,
2818
+ fill_value = np . nan , limit = None , tolerance = None ):
2819
2819
new_columns , indexer = self .columns .reindex (new_columns , method = method ,
2820
2820
level = level , limit = limit ,
2821
2821
tolerance = tolerance )
@@ -3794,7 +3794,7 @@ def _combine_series(self, other, func, fill_value=None, axis=None,
3794
3794
def _combine_series_infer (self , other , func , level = None ,
3795
3795
fill_value = None , try_cast = True ):
3796
3796
if len (other ) == 0 :
3797
- return self * NA
3797
+ return self * np . nan
3798
3798
3799
3799
if len (self ) == 0 :
3800
3800
# Ambiguous case, use _series so works with DataFrame
@@ -3948,7 +3948,7 @@ def combine(self, other, func, fill_value=None, overwrite=True):
3948
3948
3949
3949
if do_fill :
3950
3950
arr = _ensure_float (arr )
3951
- arr [this_mask & other_mask ] = NA
3951
+ arr [this_mask & other_mask ] = np . nan
3952
3952
3953
3953
# try to downcast back to the original dtype
3954
3954
if needs_i8_conversion_i :
@@ -4567,7 +4567,7 @@ def _apply_empty_result(self, func, axis, reduce, *args, **kwds):
4567
4567
pass
4568
4568
4569
4569
if reduce :
4570
- return Series (NA , index = self ._get_agg_axis (axis ))
4570
+ return Series (np . nan , index = self ._get_agg_axis (axis ))
4571
4571
else :
4572
4572
return self .copy ()
4573
4573
@@ -5185,7 +5185,7 @@ def corr(self, method='pearson', min_periods=1):
5185
5185
5186
5186
valid = mask [i ] & mask [j ]
5187
5187
if valid .sum () < min_periods :
5188
- c = NA
5188
+ c = np . nan
5189
5189
elif i == j :
5190
5190
c = 1.
5191
5191
elif not valid .all ():
@@ -5509,7 +5509,7 @@ def idxmin(self, axis=0, skipna=True):
5509
5509
axis = self ._get_axis_number (axis )
5510
5510
indices = nanops .nanargmin (self .values , axis = axis , skipna = skipna )
5511
5511
index = self ._get_axis (axis )
5512
- result = [index [i ] if i >= 0 else NA for i in indices ]
5512
+ result = [index [i ] if i >= 0 else np . nan for i in indices ]
5513
5513
return Series (result , index = self ._get_agg_axis (axis ))
5514
5514
5515
5515
def idxmax (self , axis = 0 , skipna = True ):
@@ -5540,7 +5540,7 @@ def idxmax(self, axis=0, skipna=True):
5540
5540
axis = self ._get_axis_number (axis )
5541
5541
indices = nanops .nanargmax (self .values , axis = axis , skipna = skipna )
5542
5542
index = self ._get_axis (axis )
5543
- result = [index [i ] if i >= 0 else NA for i in indices ]
5543
+ result = [index [i ] if i >= 0 else np . nan for i in indices ]
5544
5544
return Series (result , index = self ._get_agg_axis (axis ))
5545
5545
5546
5546
def _get_agg_axis (self , axis_num ):
@@ -5778,9 +5778,8 @@ def isin(self, values):
5778
5778
2 True True
5779
5779
"""
5780
5780
if isinstance (values , dict ):
5781
- from collections import defaultdict
5782
5781
from pandas .core .reshape .concat import concat
5783
- values = defaultdict (list , values )
5782
+ values = collections . defaultdict (list , values )
5784
5783
return concat ((self .iloc [:, [i ]].isin (values [col ])
5785
5784
for i , col in enumerate (self .columns )), axis = 1 )
5786
5785
elif isinstance (values , Series ):
@@ -6143,7 +6142,7 @@ def _homogenize(data, index, dtype=None):
6143
6142
v = _dict_compat (v )
6144
6143
else :
6145
6144
v = dict (v )
6146
- v = lib .fast_multiget (v , oindex .values , default = NA )
6145
+ v = lib .fast_multiget (v , oindex .values , default = np . nan )
6147
6146
v = _sanitize_array (v , index , dtype = dtype , copy = False ,
6148
6147
raise_cast_failure = False )
6149
6148
0 commit comments