Appending values to a Series in Pandas
Appending a single value using square brackets
To append a single value:
s = pd.Series([3,4], index=["a","b"])s["c"] = 5sa 3b 4c 5dtype: int64
Appending a value to a Series is cost intensive because a new Series must be created. If you need to append multiple values, it is highly recommended to append them in one go (using
concat(~)), rather than one by one.
Appending multiple values using concat
To append values to a Series in Pandas, use the
If you want to append values held in a Python standard list, first convert the list into a Series as we have done above.