@@ -233,7 +233,7 @@ def f(self, other, axis=default_axis, level=None, fill_value=None):
233
233
return self ._combine_series (casted , na_op , fill_value ,
234
234
axis , level )
235
235
elif other .ndim == 2 :
236
- casted = DataFrame (other , index = self .index ,
236
+ casted = self . _constructor (other , index = self .index ,
237
237
columns = self .columns )
238
238
return self ._combine_frame (casted , na_op , fill_value , level )
239
239
else : # pragma: no cover
@@ -297,7 +297,7 @@ def f(self, other, axis=default_axis, level=None):
297
297
return self ._combine_series (casted , na_op , None , axis , level )
298
298
299
299
elif other .ndim == 2 :
300
- casted = DataFrame (other , index = self .index ,
300
+ casted = self . _constructor (other , index = self .index ,
301
301
columns = self .columns )
302
302
303
303
return self ._flex_compare_frame (casted , na_op , str_rep , level )
@@ -1771,7 +1771,7 @@ def as_blocks(self, columns=None):
1771
1771
bd = dict ()
1772
1772
for b in self ._data .blocks :
1773
1773
b = b .reindex_items_from (columns or b .items )
1774
- bd [str (b .dtype )] = DataFrame (BlockManager ([ b ], [ b .items , self .index ]))
1774
+ bd [str (b .dtype )] = self . _constructor (BlockManager ([ b ], [ b .items , self .index ]))
1775
1775
return bd
1776
1776
1777
1777
blocks = property (fget = as_blocks )
@@ -1841,12 +1841,12 @@ def _unpickle_matrix_compat(self, state): # pragma: no cover
1841
1841
(vals , idx , cols ), object_state = state
1842
1842
1843
1843
index = _unpickle_array (idx )
1844
- dm = DataFrame (vals , index = index , columns = _unpickle_array (cols ),
1844
+ dm = self . _constructor (vals , index = index , columns = _unpickle_array (cols ),
1845
1845
copy = False )
1846
1846
1847
1847
if object_state is not None :
1848
1848
ovals , _ , ocols = object_state
1849
- objects = DataFrame (ovals , index = index ,
1849
+ objects = self . _constructor (ovals , index = index ,
1850
1850
columns = _unpickle_array (ocols ),
1851
1851
copy = False )
1852
1852
@@ -2041,7 +2041,7 @@ def _getitem_multilevel(self, key):
2041
2041
result .columns = result_columns
2042
2042
else :
2043
2043
new_values = self .values [:, loc ]
2044
- result = DataFrame (new_values , index = self .index ,
2044
+ result = self . _constructor (new_values , index = self .index ,
2045
2045
columns = result_columns )
2046
2046
if len (result .columns ) == 1 :
2047
2047
top = result .columns [0 ]
@@ -2558,7 +2558,7 @@ def _align_series(self, other, join='outer', axis=None, level=None,
2558
2558
if copy and fdata is self ._data :
2559
2559
fdata = fdata .copy ()
2560
2560
2561
- left_result = DataFrame (fdata )
2561
+ left_result = self . _constructor (fdata )
2562
2562
right_result = other if ridx is None else other .reindex (join_index )
2563
2563
2564
2564
fill_na = notnull (fill_value ) or (method is not None )
@@ -2737,7 +2737,7 @@ def _reindex_with_indexers(self, index, row_indexer, columns, col_indexer,
2737
2737
if copy and new_data is self ._data :
2738
2738
new_data = new_data .copy ()
2739
2739
2740
- return DataFrame (new_data )
2740
+ return self . _constructor (new_data )
2741
2741
2742
2742
def reindex_like (self , other , method = None , copy = True , limit = None ,
2743
2743
fill_value = NA ):
@@ -2985,7 +2985,7 @@ def take(self, indices, axis=0, convert=True):
2985
2985
if self ._is_mixed_type :
2986
2986
if axis == 0 :
2987
2987
new_data = self ._data .take (indices , axis = 1 , verify = False )
2988
- return DataFrame (new_data )
2988
+ return self . _constructor (new_data )
2989
2989
else :
2990
2990
new_columns = self .columns .take (indices )
2991
2991
return self .reindex (columns = new_columns )
@@ -2999,7 +2999,7 @@ def take(self, indices, axis=0, convert=True):
2999
2999
else :
3000
3000
new_columns = self .columns .take (indices )
3001
3001
new_index = self .index
3002
- return DataFrame (new_values , index = new_index ,
3002
+ return self . _constructor (new_values , index = new_index ,
3003
3003
columns = new_columns )
3004
3004
3005
3005
#----------------------------------------------------------------------
@@ -4075,7 +4075,7 @@ def update(self, other, join='left', overwrite=True, filter_func=None,
4075
4075
raise NotImplementedError
4076
4076
4077
4077
if not isinstance (other , DataFrame ):
4078
- other = DataFrame (other )
4078
+ other = self . _constructor (other )
4079
4079
4080
4080
other = other .reindex_like (self )
4081
4081
@@ -4425,7 +4425,7 @@ def _apply_raw(self, func, axis):
4425
4425
4426
4426
# TODO: mixed type case
4427
4427
if result .ndim == 2 :
4428
- return DataFrame (result , index = self .index ,
4428
+ return self . _constructor (result , index = self .index ,
4429
4429
columns = self .columns )
4430
4430
else :
4431
4431
return Series (result , index = self ._get_agg_axis (axis ))
@@ -4592,10 +4592,10 @@ def append(self, other, ignore_index=False, verify_integrity=False):
4592
4592
4593
4593
index = None if other .name is None else [other .name ]
4594
4594
other = other .reindex (self .columns , copy = False )
4595
- other = DataFrame (other .values .reshape ((1 , len (other ))),
4595
+ other = self . _constructor (other .values .reshape ((1 , len (other ))),
4596
4596
index = index , columns = self .columns )
4597
4597
elif isinstance (other , list ) and not isinstance (other [0 ], DataFrame ):
4598
- other = DataFrame (other )
4598
+ other = self . _constructor (other )
4599
4599
if (self .columns .get_indexer (other .columns ) >= 0 ).all ():
4600
4600
other = other .ix [:, self .columns ]
4601
4601
@@ -4660,7 +4660,7 @@ def _join_compat(self, other, on=None, how='left', lsuffix='', rsuffix='',
4660
4660
if isinstance (other , Series ):
4661
4661
if other .name is None :
4662
4662
raise AssertionError ('Other Series must have a name' )
4663
- other = DataFrame ({other .name : other })
4663
+ other = self . _constructor ({other .name : other })
4664
4664
4665
4665
if isinstance (other , DataFrame ):
4666
4666
return merge (self , other , left_on = on , how = how ,
@@ -4862,7 +4862,7 @@ def describe(self, percentile_width=50):
4862
4862
numdata = self ._get_numeric_data ()
4863
4863
4864
4864
if len (numdata .columns ) == 0 :
4865
- return DataFrame (dict ((k , v .describe ())
4865
+ return self . _constructor (dict ((k , v .describe ())
4866
4866
for k , v in self .iteritems ()),
4867
4867
columns = self .columns )
4868
4868
@@ -4954,7 +4954,7 @@ def _count_level(self, level, axis=0, numeric_only=False):
4954
4954
labels = com ._ensure_int64 (frame .index .labels [level ])
4955
4955
counts = lib .count_level_2d (mask , labels , len (level_index ))
4956
4956
4957
- result = DataFrame (counts , index = level_index ,
4957
+ result = self . _constructor (counts , index = level_index ,
4958
4958
columns = frame .columns )
4959
4959
4960
4960
if axis == 1 :
0 commit comments