Python Practice › Pandas Programs › Program 15
Add data to a Series
Write a pandas program to add new values to an existing Series.
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
pd.concatwith a new Series.
Solution
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.
Learn the concept
New to this topic? Read the lesson, then come back.