@@ -6564,63 +6564,16 @@ def apply(self, func, axis=0, raw=False, result_type=None, args=(), **kwds):
6564
6564
"""
6565
6565
from pandas .core .apply import frame_apply
6566
6566
6567
- # Old apply function, which will be used for each part of DataFrame
6568
- def partial_apply (dataframe ):
6569
- op = frame_apply (
6570
- dataframe ,
6571
- func = func ,
6572
- axis = axis ,
6573
- raw = raw ,
6574
- result_type = result_type ,
6575
- args = args ,
6576
- kwds = kwds ,
6577
- )
6578
- return op .get_result ()
6579
-
6580
- def get_dtype (dataframe , column ):
6581
- return dataframe .dtypes .values [column ]
6582
-
6583
- if axis == 0 or axis == "index" :
6584
- if self .shape [1 ] == 0 :
6585
- return partial_apply (self )
6586
-
6587
- frame = self .iloc [:, [0 ]]
6588
- result = partial_apply (frame )
6589
- if isinstance (result , Series ):
6590
- results = result .values
6591
- else :
6592
- results = result
6593
-
6594
- i = 1
6595
- while i < self .shape [1 ]:
6596
- type = get_dtype (self , i )
6597
- j = i + 1
6598
-
6599
- # While the dtype of column is the same as previous ones,
6600
- # they are handled together
6601
- while j < self .shape [1 ] and pandas .core .dtypes .common .is_dtype_equal (
6602
- type , get_dtype (self , j )
6603
- ):
6604
- j += 1
6605
- frame = self .iloc [:, i :j ]
6606
- i = j
6607
- result = partial_apply (frame )
6608
-
6609
- if isinstance (result , Series ):
6610
- results = np .append (results , result .values )
6611
- else :
6612
- for k in range (result .shape [0 ], results .shape [0 ]):
6613
- result .loc [k , :] = np .nan
6614
- for k in range (results .shape [0 ], result .shape [0 ]):
6615
- results .loc [k , :] = np .nan
6616
- results = pandas .concat ([results , result ], axis = 1 )
6617
-
6618
- if isinstance (result , Series ):
6619
- return Series (results , index = self .columns )
6620
- else :
6621
- return results
6622
- else :
6623
- return partial_apply (self )
6567
+ op = frame_apply (
6568
+ self ,
6569
+ func = func ,
6570
+ axis = axis ,
6571
+ raw = raw ,
6572
+ result_type = result_type ,
6573
+ args = args ,
6574
+ kwds = kwds ,
6575
+ )
6576
+ return op .get_result ()
6624
6577
6625
6578
def applymap (self , func ):
6626
6579
"""
0 commit comments