Search code examples
pythonpandassubtraction

Pandas Issue subtracting a series from a dataframe column


I am subtracting a series from a dataframe column.

df

                daily_return    daily_weight

2003-01-01T          1.2            62
2003-01-02T          1.3            63
2003-01-03T          1.1            64
 ...

and series

                    Return
2003-01-01T          1.2            
2003-01-02T          1.3            
2003-01-03T          1.1            
 ...

indices are identical datetime indexes. I use the following sytnax:

df['Daily Return'].subtract(s['Return'],axis=0)

The result I get is:

ValueError: cannot reindex from a duplicate axis

What am I doing wrong?


Solution

  • Thank you everyone.

    It was actually a data issue. Data was being somehow transformed and indices in one index was corrupted on import. code was good.

    I would vote myself down one if I could.