Python Practice › Pandas Programs › Program 15

Add data to a Series

EasyPandas Programs · 15 of 95

Write a pandas program to add new values to an existing Series.

Advertisement
Input
["54", "27.90", "sqa", "33.33", "tools"] + ["python", "100"]
Output
0        54
1     27.90
2       sqa
3     33.33
4     tools
5    python
6       100
dtype: str

Approach

  1. pd.concat with a new Series.

Solution

Python
import pandas as pds = pd.Series(["54", "27.90", "sqa", "33.33", "tools"])s = pd.concat([s, pd.Series(["python", "100"])], ignore_index=True)print(s)
Output
0        54
1     27.90
2       sqa
3     33.33
4     tools
5    python
6       100
dtype: str

Line by line

Line 3

ignore_index=True renumbers the result 0 to 6.

Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More pandas programs

← All 95 Pandas Programs