  We study the interplay of 3d and 4f electrons in the iron pnictides
CeFe$_{1-x}$Co$_x$AsO and GdFe$_{1-y}$Co$_y$AsO, which correspond to two very
different cases of $4f$-magnetic moment. Both CeFeAsO and GdFeAsO undergo a
spin-density-wave (SDW) transition associated with Fe 3d electrons at high
temperatures, which is rapidly suppressed by Fe/Co substitution.
Superconductivity appears in a narrow doping range: $0.05 < x < 0.2$ for
CeFe$_{1-x}$Co$_x$AsO and $0.05 < y < 0.25$ for GdFe$_{1-y}$Co$_y$AsO, showing
a maximum transition temperature $T_\textup{sc}$ of about 13.5 K for Ce and 19
K for Gd. In both compounds, the $4f$-electrons form an antiferromagnetic (AFM)
order at low temperatures over the entire doping range and Co 3d electrons are
ferromagnetically ordered on the Co-rich side; the Curie temperature reaches
$T_\textup{C}^\textup{Co} \approx$ 75 K at $x = 1$ and $y = 1$. In the
Ce-compounds, the N\'{e}el temperature $T_\textup{N}^\textup{Ce}$ increases
upon suppressing the SDW transition of Fe and then remains nearly unchanged
with further increasing Co concentration up to $x \simeq 0.8$
($T_\textup{N}^\textup{Ce}\approx$ 4 K). Furthermore, evidence of Co-induced
polarization on Ce-moments is observed on the Co-rich side. In the
Gd-compounds, the two magnetic species of Gd and Co are coupled
antiferromagnetically to give rise to ferrimagnetic behavior in the magnetic
susceptibility on the Co-rich side. For $0.7 \leq y < 1.0$, the system
undergoes a possible magnetic reorientation below the N\'{e}el temperature of
Gd ($T_\textup{N}^\textup{Gd}$). Our results suggest that the effects of both
electron hybridizations and magnetic exchange coupling between the 3d-4f
electrons give rise to a rich phase diagram in the rare-earth iron pnictides.
