In this python pandas program, we will add some data to an existing series using pandas library.
Steps to solve the program
- Import pandas library as pd.
- Create a series using pd.Series().
- Now add some data to the series using df.append(pd.Series([data])).
- Print the output.
import pandas as pd
df = pd.Series([54,27.9,'sqa',33.33,'tools'])
print("Original Data Series:")
print(df)
print("Data Series after adding some data:")
new = df.append(pd.Series(['python',100]))
print(new)
Output :
Original Data Series:
0 54
1 27.9
2 sqa
3 33.33
4 tools
dtype: object
Data Series after adding some data:
0 54
1 27.9
2 sqa
3 33.33
4 tools
0 python
1 100
dtype: object