-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Closed
Labels
DatetimeDatetime data dtypeDatetime data dtypeDtype ConversionsUnexpected or buggy dtype conversionsUnexpected or buggy dtype conversions
Milestone
Description
In DataFrame.combine, we handle datetimelike data special.
Line 5116 in 296c251
needs_i8_conversion_i = needs_i8_conversion(new_dtype) |
We attempt to pass a third argument to the combining func
. This breaks things like
In [16]: def combiner(x, y): return x
In [17]: a = pd.DataFrame({"A": range(4)})
In [18]: b = pd.DataFrame({"A": pd.date_range('2017', periods=4)})
In [19]: a.combine(a, combiner)
Out[19]:
A
0 0
1 1
2 2
3 3
In [20]: b.combine(b, combiner)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-20-3271f7709d72> in <module>
----> 1 b.combine(b, combiner)
~/sandbox/pandas/pandas/core/frame.py in combine(self, other, func, fill_value, overwrite)
5116 needs_i8_conversion_i = needs_i8_conversion(new_dtype)
5117 if needs_i8_conversion_i:
-> 5118 arr = func(series, otherSeries, True)
5119 else:
5120 arr = func(series, otherSeries)
TypeError: combiner() takes 2 positional arguments but 3 were given
We could document that, but it still feels hacky. I'd rather that the combiner
func infer whether an i8 conversion is needed.
xref #3595
Metadata
Metadata
Assignees
Labels
DatetimeDatetime data dtypeDatetime data dtypeDtype ConversionsUnexpected or buggy dtype conversionsUnexpected or buggy dtype conversions