combine(self, other, func, fill_value=None) -> 'Series'
Combine the Series and other
using func
to perform elementwise selection for combined Series. :None:None:`fill_value`
is assumed when value is missing at some index from one of the two objects being combined.
The value(s) to be combined with the Series
.
Function that takes two scalars as inputs and returns an element.
The value to assume when an index is missing from one Series or the other. The default specifies to use the appropriate NaN value for the underlying dtype of the Series.
The result of combining the Series with the other object.
Combine the Series with a Series or scalar according to func
.
Series.combine_first
Combine Series values, choosing the calling Series' values first.
Consider 2 Datasets s1
and s2
containing highest clocked speeds of different birds.
>>> s1 = pd.Series({'falcon': 330.0, 'eagle': 160.0})This example is valid syntax, but we were not able to check execution
... s1 falcon 330.0 eagle 160.0 dtype: float64
>>> s2 = pd.Series({'falcon': 345.0, 'eagle': 200.0, 'duck': 30.0})
... s2 falcon 345.0 eagle 200.0 duck 30.0 dtype: float64
Now, to combine the two datasets and view the highest speeds of the birds across the two datasets
This example is valid syntax, but we were not able to check execution>>> s1.combine(s2, max) duck NaN eagle 200.0 falcon 345.0 dtype: float64
In the previous example, the resulting value for duck is missing, because the maximum of a NaN and a float is a NaN. So, in the example, we set fill_value=0
, so the maximum value returned will be the value from some dataset.
>>> s1.combine(s2, max, fill_value=0) duck 30.0 eagle 200.0 falcon 345.0 dtype: float64See :
The following pages refer to to this document either explicitly or contain code examples using this.
pandas.core.series.Series.combine_first
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them