Skip to content

Commit 5a0c91e

Browse files
jbrockmendeljreback
authored andcommitted
remove unused try_cast kwarg (#23258)
1 parent 104ccfd commit 5a0c91e

File tree

4 files changed

+21
-24
lines changed

4 files changed

+21
-24
lines changed

pandas/core/frame.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4971,14 +4971,14 @@ def _combine_match_index(self, other, func, level=None):
49714971
index=left.index, columns=self.columns,
49724972
copy=False)
49734973

4974-
def _combine_match_columns(self, other, func, level=None, try_cast=True):
4974+
def _combine_match_columns(self, other, func, level=None):
49754975
assert isinstance(other, Series)
49764976
left, right = self.align(other, join='outer', axis=1, level=level,
49774977
copy=False)
49784978
assert left.columns.equals(right.index)
49794979
return ops.dispatch_to_series(left, right, func, axis="columns")
49804980

4981-
def _combine_const(self, other, func, errors='raise', try_cast=True):
4981+
def _combine_const(self, other, func, errors='raise'):
49824982
assert lib.is_scalar(other) or np.ndim(other) == 0
49834983
return ops.dispatch_to_series(self, other, func)
49844984

pandas/core/ops.py

+13-16
Original file line numberDiff line numberDiff line change
@@ -1726,10 +1726,10 @@ def column_op(a, b):
17261726

17271727

17281728
def _combine_series_frame(self, other, func, fill_value=None, axis=None,
1729-
level=None, try_cast=True):
1729+
level=None):
17301730
"""
17311731
Apply binary operator `func` to self, other using alignment and fill
1732-
conventions determined by the fill_value, axis, level, and try_cast kwargs.
1732+
conventions determined by the fill_value, axis, and level kwargs.
17331733
17341734
Parameters
17351735
----------
@@ -1739,7 +1739,6 @@ def _combine_series_frame(self, other, func, fill_value=None, axis=None,
17391739
fill_value : object, default None
17401740
axis : {0, 1, 'columns', 'index', None}, default None
17411741
level : int or None, default None
1742-
try_cast : bool, default True
17431742
17441743
Returns
17451744
-------
@@ -1754,8 +1753,7 @@ def _combine_series_frame(self, other, func, fill_value=None, axis=None,
17541753
if axis == 0:
17551754
return self._combine_match_index(other, func, level=level)
17561755
else:
1757-
return self._combine_match_columns(other, func, level=level,
1758-
try_cast=try_cast)
1756+
return self._combine_match_columns(other, func, level=level)
17591757
else:
17601758
if not len(other):
17611759
return self * np.nan
@@ -1766,8 +1764,7 @@ def _combine_series_frame(self, other, func, fill_value=None, axis=None,
17661764
columns=self.columns)
17671765

17681766
# default axis is columns
1769-
return self._combine_match_columns(other, func, level=level,
1770-
try_cast=try_cast)
1767+
return self._combine_match_columns(other, func, level=level)
17711768

17721769

17731770
def _align_method_FRAME(left, right, axis):
@@ -1867,13 +1864,13 @@ def f(self, other, axis=default_axis, level=None, fill_value=None):
18671864
pass_op = op if axis in [0, "columns", None] else na_op
18681865
return _combine_series_frame(self, other, pass_op,
18691866
fill_value=fill_value, axis=axis,
1870-
level=level, try_cast=True)
1867+
level=level)
18711868
else:
18721869
if fill_value is not None:
18731870
self = self.fillna(fill_value)
18741871

18751872
assert np.ndim(other) == 0
1876-
return self._combine_const(other, op, try_cast=True)
1873+
return self._combine_const(other, op)
18771874

18781875
f.__name__ = op_name
18791876

@@ -1909,9 +1906,10 @@ def f(self, other, axis=default_axis, level=None):
19091906
elif isinstance(other, ABCSeries):
19101907
return _combine_series_frame(self, other, na_op,
19111908
fill_value=None, axis=axis,
1912-
level=level, try_cast=False)
1909+
level=level)
19131910
else:
1914-
return self._combine_const(other, na_op, try_cast=False)
1911+
assert np.ndim(other) == 0, other
1912+
return self._combine_const(other, na_op)
19151913

19161914
f.__name__ = op_name
19171915

@@ -1937,14 +1935,13 @@ def f(self, other):
19371935
elif isinstance(other, ABCSeries):
19381936
return _combine_series_frame(self, other, func,
19391937
fill_value=None, axis=None,
1940-
level=None, try_cast=False)
1938+
level=None)
19411939
else:
19421940

19431941
# straight boolean comparisons we want to allow all columns
19441942
# (regardless of dtype to pass thru) See #4537 for discussion.
19451943
res = self._combine_const(other, func,
1946-
errors='ignore',
1947-
try_cast=False)
1944+
errors='ignore')
19481945
return res.fillna(True).astype(bool)
19491946

19501947
f.__name__ = op_name
@@ -1991,13 +1988,13 @@ def f(self, other, axis=None):
19911988
self._get_axis_number(axis)
19921989

19931990
if isinstance(other, self._constructor):
1994-
return self._compare_constructor(other, na_op, try_cast=False)
1991+
return self._compare_constructor(other, na_op)
19951992
elif isinstance(other, (self._constructor_sliced, ABCDataFrame,
19961993
ABCSeries)):
19971994
raise Exception("input needs alignment for this object [{object}]"
19981995
.format(object=self._constructor))
19991996
else:
2000-
return self._combine_const(other, na_op, try_cast=False)
1997+
return self._combine_const(other, na_op)
20011998

20021999
f.__name__ = op_name
20032000

pandas/core/panel.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ def _init_matrix(self, data, axes, dtype=None, copy=False):
330330
# ----------------------------------------------------------------------
331331
# Comparison methods
332332

333-
def _compare_constructor(self, other, func, try_cast=True):
333+
def _compare_constructor(self, other, func):
334334
if not self._indexed_same(other):
335335
raise Exception('Can only compare identically-labeled '
336336
'same type objects')
@@ -745,13 +745,13 @@ def _combine(self, other, func, axis=0):
745745
"{otype!s} is not supported in combine operation with "
746746
"{selftype!s}".format(otype=type(other), selftype=type(self)))
747747

748-
def _combine_const(self, other, func, try_cast=True):
748+
def _combine_const(self, other, func):
749749
with np.errstate(all='ignore'):
750750
new_values = func(self.values, other)
751751
d = self._construct_axes_dict()
752752
return self._constructor(new_values, **d)
753753

754-
def _combine_frame(self, other, func, axis=0, try_cast=True):
754+
def _combine_frame(self, other, func, axis=0):
755755
index, columns = self._get_plane_axes(axis)
756756
axis = self._get_axis_number(axis)
757757

@@ -770,7 +770,7 @@ def _combine_frame(self, other, func, axis=0, try_cast=True):
770770
return self._constructor(new_values, self.items, self.major_axis,
771771
self.minor_axis)
772772

773-
def _combine_panel(self, other, func, try_cast=True):
773+
def _combine_panel(self, other, func):
774774
items = self.items.union(other.items)
775775
major = self.major_axis.union(other.major_axis)
776776
minor = self.minor_axis.union(other.minor_axis)

pandas/core/sparse/frame.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ def _combine_match_index(self, other, func, level=None):
618618
new_data, index=new_index, columns=self.columns,
619619
default_fill_value=fill_value).__finalize__(self)
620620

621-
def _combine_match_columns(self, other, func, level=None, try_cast=True):
621+
def _combine_match_columns(self, other, func, level=None):
622622
# patched version of DataFrame._combine_match_columns to account for
623623
# NumPy circumventing __rsub__ with float64 types, e.g.: 3.0 - series,
624624
# where 3.0 is numpy.float64 and series is a SparseSeries. Still
@@ -642,7 +642,7 @@ def _combine_match_columns(self, other, func, level=None, try_cast=True):
642642
new_data, index=self.index, columns=union,
643643
default_fill_value=self.default_fill_value).__finalize__(self)
644644

645-
def _combine_const(self, other, func, errors='raise', try_cast=True):
645+
def _combine_const(self, other, func, errors='raise'):
646646
return self._apply_columns(lambda x: func(x, other))
647647

648648
def _reindex_index(self, index, method, copy, level, fill_value=np.nan,

0 commit comments

Comments
 (0)