-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Closed
Labels
ExtensionArrayExtending pandas with custom dtypes or arrays.Extending pandas with custom dtypes or arrays.IndexRelated to the Index class or subclassesRelated to the Index class or subclassesNeeds TestsUnit test(s) needed to prevent regressionsUnit test(s) needed to prevent regressionsNumeric OperationsArithmetic, Comparison, and Logical operationsArithmetic, Comparison, and Logical operations
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
.
Metadata
Metadata
Assignees
Labels
ExtensionArrayExtending pandas with custom dtypes or arrays.Extending pandas with custom dtypes or arrays.IndexRelated to the Index class or subclassesRelated to the Index class or subclassesNeeds TestsUnit test(s) needed to prevent regressionsUnit test(s) needed to prevent regressionsNumeric OperationsArithmetic, Comparison, and Logical operationsArithmetic, Comparison, and Logical operations