Closed
Description
Here is a snippet of code summarizing the issue (pandas 1.4.2, various versions of python).
import pandas as pd
d = pd.DataFrame(columns=list('abc'), data=0.0, index=[0])
e = pd.DataFrame(columns=list('abc'), data=0.0, index=[0])
e.columns = e.columns.astype('string')
d+e ## raises an unexpected exception
The simple addition of 2 arrays of apparently the same shape ends with the following exception:
ValueError: Location based indexing can only have [integer, integer slice
(START point is INCLUDED, END point is EXCLUDED), listlike of integers,
boolean array] types
The dtypes of the columns of p1 and p2 are respectively:
>>> p1.columns.dtype
dtype('O')
>>> p2.columns.dtype
string[python]
and that seems to cause the issue.
I would expect the formula p1+p2
to work like p1+p1
.