Skip to content

Commit 1a7d7c8

Browse files
committed
rename infer to expand
1 parent 8e8c41b commit 1a7d7c8

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

pandas/core/apply.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,8 @@ def wrap_results_for_axis(self):
358358
""" return the results for the columns """
359359
results = self.results
360360

361-
# we have requested inference
362-
if self.result_type == 'infer':
361+
# we have requested to expand
362+
if self.result_type == 'expand':
363363
result = self.infer_to_same_shape()
364364

365365
# we have a non-series and don't want inference

pandas/core/frame.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4871,9 +4871,9 @@ def apply(self, func, axis=0, broadcast=None, raw=False, reduce=None,
48714871
reduce is True a Series will always be returned, and if False a
48724872
DataFrame will always be returned.
48734873
4874-
result_type : {'infer', 'broadcast, None}
4874+
result_type : {'expand', 'broadcast, None}
48754875
These only act when axis=1 {columns}
4876-
* 'infer' : list-like results will be turned into columns
4876+
* 'expand' : list-like results will be turned into columns
48774877
* 'broadcast' : scalar results will be broadcast to all columns
48784878
* None : list-like results will be returned as a list
48794879
in a single column. However if the apply function
@@ -4948,10 +4948,10 @@ def apply(self, func, axis=0, broadcast=None, raw=False, reduce=None,
49484948
4 [1, 2]
49494949
5 [1, 2]
49504950
4951-
Passing result_type='infer' will expand list-like results
4951+
Passing result_type='expand' will expand list-like results
49524952
to columns of a Dataframe
49534953
4954-
>>> df.apply(lambda x: [1, 2], axis=1, result_type='infer')
4954+
>>> df.apply(lambda x: [1, 2], axis=1, result_type='expand')
49554955
0 1
49564956
0 1 2
49574957
1 1 2

pandas/core/sparse/frame.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -853,9 +853,9 @@ def apply(self, func, axis=0, broadcast=None, reduce=False,
853853
This argument will be removed in a future version, replaced
854854
by result_type='broadcast'.
855855
856-
result_type : {'infer', 'broadcast, None}
856+
result_type : {'expand', 'broadcast, None}
857857
These only act when axis=1 {columns}
858-
* 'infer' : list-like results will be turned into columns
858+
* 'expand' : list-like results will be turned into columns
859859
* 'broadcast' : scalar results will be broadcast to all columns
860860
* None : list-like results will be returned as a list
861861
in a single column. However if the apply function

pandas/tests/frame/test_apply.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -576,14 +576,14 @@ def test_with_dictlike_columns_with_infer(self):
576576
# gh 17602
577577
df = DataFrame([[1, 2], [1, 2]], columns=['a', 'b'])
578578
result = df.apply(lambda x: {'s': x['a'] + x['b']},
579-
axis=1, result_type='infer')
579+
axis=1, result_type='expand')
580580
expected = DataFrame({'s': [3, 3]})
581581
assert_frame_equal(result, expected)
582582

583583
df['tm'] = [pd.Timestamp('2017-05-01 00:00:00'),
584584
pd.Timestamp('2017-05-02 00:00:00')]
585585
result = df.apply(lambda x: {'s': x['a'] + x['b']},
586-
axis=1, result_type='infer')
586+
axis=1, result_type='expand')
587587
assert_frame_equal(result, expected)
588588

589589
def test_with_listlike_columns(self):
@@ -705,12 +705,12 @@ def test_result_type(self):
705705
np.tile(np.arange(3, dtype='int64'), 6).reshape(6, -1) + 1,
706706
columns=['A', 'B', 'C'])
707707

708-
result = df.apply(lambda x: [1, 2, 3], axis=1, result_type='infer')
708+
result = df.apply(lambda x: [1, 2, 3], axis=1, result_type='expand')
709709
expected = df.copy()
710710
expected.columns = [0, 1, 2]
711711
assert_frame_equal(result, expected)
712712

713-
result = df.apply(lambda x: [1, 2], axis=1, result_type='infer')
713+
result = df.apply(lambda x: [1, 2], axis=1, result_type='expand')
714714
expected = df[['A', 'B']].copy()
715715
expected.columns = [0, 1]
716716
assert_frame_equal(result, expected)
@@ -760,7 +760,7 @@ def test_consistency_for_boxed(self, box):
760760
expected = Series([box([1, 2]) for t in df.itertuples()])
761761
assert_series_equal(result, expected)
762762

763-
result = df.apply(lambda x: box([1, 2]), axis=1, result_type='infer')
763+
result = df.apply(lambda x: box([1, 2]), axis=1, result_type='expand')
764764
expected = DataFrame(
765765
np.tile(np.arange(2, dtype='int64'), 6).reshape(6, -1) + 1)
766766
assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)