Skip to main content
Engineering LibreTexts

12.5: Concatenating and Combining

  • Page ID
    39282
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    Finally, it is sometimes convenient to be able to combine two or more Serieses into a single one. But there’s a catch. Remember that in order for a Series to “work properly,” its keys must be unique. Combining two Series which share at least one of the same keys is a recipe for disaster!

    The syntax for doing so, when the coast is clear, uses the .append() method:

    Code \(\PageIndex{1}\) (Python):

    crazy_example = salaries.append(slayers)

    print(crazy_example)

    | Michael 113.0

    | Dwight 68.0

    | Pam 67.0

    | Jim 100.2

    | Ryan 68.0

    | Xander 72.0

    | Willow 200.0

    | Rubert 150.0

    | Buffy 120.0

    | dtype: float64

    Nothing untoward happened here because The Office and Buffy don’t have any overlapping character names. Note that the values all got converted to float (instead of int), to enforce homogeneity. Note also that salaries itself did not change as a result of this .append() call; instead, a new Series was returned that contains all the items.


    This page titled 12.5: Concatenating and Combining is shared under a CC BY-SA 4.0 license and was authored, remixed, and/or curated by Stephen Davies (allthemath.org) via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.

    • Was this article helpful?