1

I will have an iterating process creating a set of similar, but not identical pandas series by index.

I want to append one to the other but overwrite where applicable. eg

Series One:

Index Value
Jan    3
Feb    5
Mar    4

Series Two:

Index Value
Mar    10
Apr    5
May    7

Desired Output:

Jan    3
Feb    5
Mar    10
Apr    5
May    7

Thanks in advance.

Tikhon
  • 451
  • 1
  • 5
  • 13
  • You can append dataframes. I found this. https://stackoverflow.com/questions/21317384/pandas-python-how-to-concatenate-two-dataframes-without-duplicates – Bryce Wayne Apr 29 '20 at 01:45

1 Answers1

3

Let us do

s=s2.combine_first(s1)
Index
Apr     5.0
Feb     5.0
Jan     3.0
Mar    10.0
May     7.0
Name: Value, dtype: float64

Or

s1.append(s2).groupby(level=0).tail(1)
Index
Jan     3
Feb     5
Mar    10
Apr     5
May     7
Name: Value, dtype: int64
BENY
  • 317,841
  • 20
  • 164
  • 234