Add item to pandas.Series?
Using set_value
generates the warning:
FutureWarning: set_value is deprecated and will be removed in a future release. Please use .at[] or .iat[] accessors instead
So you can instead use at
like this:
input.at[input.index[-1]+1]=6
Convert appended item to Series
:
>>> ds = pd.Series([1,2,3,4,5])
>>> ds.append(pd.Series([6]))
0 1
1 2
2 3
3 4
4 5
0 6
dtype: int64
or use DataFrame
:
>>> df = pd.DataFrame(ds)
>>> df.append([6], ignore_index=True)
0
0 1
1 2
2 3
3 4
4 5
5 6
and last option if your index is without gaps,
>>> ds.set_value(max(ds.index) + 1, 6)
0 1
1 2
2 3
3 4
4 5
5 6
dtype: int64
And you can use numpy as a last resort:
>>> import numpy as np
>>> pd.Series(np.concatenate((ds.values, [6])))