@@ -3102,8 +3102,10 @@ def corr(self, method='pearson'):
3102
3102
-------
3103
3103
y : DataFrame
3104
3104
"""
3105
- cols = self ._get_numeric_columns ()
3106
- mat = self .as_matrix (cols ).T
3105
+ numeric_df = self ._get_numeric_data ()
3106
+ mat = numeric_df .values .T
3107
+ cols = numeric_df .columns
3108
+
3107
3109
corrf = nanops .get_corr_func (method )
3108
3110
K = len (cols )
3109
3111
correl = np .empty ((K , K ), dtype = float )
@@ -3128,8 +3130,9 @@ def cov(self):
3128
3130
-------
3129
3131
y : DataFrame
3130
3132
"""
3131
- cols = self ._get_numeric_columns ()
3132
- mat = self .as_matrix (cols ).T
3133
+ numeric_df = self ._get_numeric_data ()
3134
+ mat = numeric_df .values .T
3135
+ cols = numeric_df .columns
3133
3136
baseCov = np .cov (mat )
3134
3137
3135
3138
for i , j , ac , bc in self ._cov_helper (mat ):
@@ -3205,9 +3208,9 @@ def describe(self):
3205
3208
-------
3206
3209
DataFrame of summary statistics
3207
3210
"""
3208
- numeric_columns = self ._get_numeric_columns ()
3211
+ numdata = self ._get_numeric_data ()
3209
3212
3210
- if len (numeric_columns ) == 0 :
3213
+ if len (numdata . columns ) == 0 :
3211
3214
return DataFrame (dict ((k , v .describe ())
3212
3215
for k , v in self .iteritems ()),
3213
3216
columns = self .columns )
@@ -3217,13 +3220,14 @@ def describe(self):
3217
3220
3218
3221
destat = []
3219
3222
3220
- for column in numeric_columns :
3223
+ for column in numdata . columns :
3221
3224
series = self [column ]
3222
3225
destat .append ([series .count (), series .mean (), series .std (),
3223
3226
series .min (), series .quantile (.25 ), series .median (),
3224
3227
series .quantile (.75 ), series .max ()])
3225
3228
3226
- return self ._constructor (map (list , zip (* destat )), index = destat_columns , columns = numeric_columns )
3229
+ return self ._constructor (map (list , zip (* destat )), index = destat_columns ,
3230
+ columns = numdata .columns )
3227
3231
3228
3232
#----------------------------------------------------------------------
3229
3233
# ndarray-like stats methods
@@ -3252,7 +3256,7 @@ def count(self, axis=0, level=None, numeric_only=False):
3252
3256
numeric_only = numeric_only )
3253
3257
3254
3258
if numeric_only :
3255
- frame = self .ix [:, self . _get_numeric_columns ()]
3259
+ frame = self ._get_numeric_data ()
3256
3260
else :
3257
3261
frame = self
3258
3262
@@ -3486,26 +3490,6 @@ def _get_agg_axis(self, axis_num):
3486
3490
else :
3487
3491
raise Exception ('Must have 0<= axis <= 1' )
3488
3492
3489
- def _get_numeric_columns (self ):
3490
- from pandas .core .internals import ObjectBlock
3491
-
3492
- cols = []
3493
- for col , blk in zip (self .columns , self ._data .block_id_vector ):
3494
- if not isinstance (self ._data .blocks [blk ], ObjectBlock ):
3495
- cols .append (col )
3496
-
3497
- return cols
3498
-
3499
- def _get_nonnumeric_columns (self ):
3500
- from pandas .core .internals import ObjectBlock
3501
-
3502
- cols = []
3503
- for col , blk in zip (self .columns , self ._data .block_id_vector ):
3504
- if isinstance (self ._data .blocks [blk ], ObjectBlock ):
3505
- cols .append (col )
3506
-
3507
- return cols
3508
-
3509
3493
def _get_numeric_data (self ):
3510
3494
if self ._is_mixed_type :
3511
3495
num_data = self ._data .get_numeric_data ()
@@ -3516,15 +3500,6 @@ def _get_numeric_data(self):
3516
3500
else :
3517
3501
return self .ix [:, []]
3518
3502
3519
- def _get_nonnumeric_data (self ):
3520
- if self ._is_mixed_type :
3521
- return self .ix [:, self ._get_nonnumeric_columns ()]
3522
- else :
3523
- if self .values .dtype == np .object_ :
3524
- return self
3525
- else :
3526
- return self .ix [:, []]
3527
-
3528
3503
def quantile (self , q = 0.5 , axis = 0 ):
3529
3504
"""
3530
3505
Return values at the given quantile over requested axis, a la
0 commit comments