-
-
Notifications
You must be signed in to change notification settings - Fork 19k
Open
Labels
EnhancementNeeds TriageIssue that has not been reviewed by a pandas team memberIssue that has not been reviewed by a pandas team memberNumeric OperationsArithmetic, Comparison, and Logical operationsArithmetic, Comparison, and Logical operations
Description
Feature Type
-
Adding new functionality to pandas
-
Changing existing functionality in pandas
-
Removing existing functionality in pandas
Problem Description
I wish Pandas could implement arithmetic operations for DatetimeArrays and Python native lists.
Feature Description
I wish the following code could run.
from datetime import datetime
import pandas as pd
arr = pd.to_datetime(["2020-01-01", "2020-01-02"]).array
assert isinstance(arr, pd.arrays.DatetimeArray)
arr - [datetime(2019, 12, 31), datetime(2020, 1, 1)] # TypeError: unsupported operand type(s) for -: 'DatetimeArray' and 'list'
Alternative Solutions
from datetime import datetime
import pandas as pd
arr = pd.to_datetime(["2020-01-01", "2020-01-02"]).array
assert isinstance(arr, pd.arrays.DatetimeArray)
arr - pd.to_datetime([datetime(2019, 12, 31), datetime(2020, 1, 1)]).array
Additional Context
No response
Metadata
Metadata
Assignees
Labels
EnhancementNeeds TriageIssue that has not been reviewed by a pandas team memberIssue that has not been reviewed by a pandas team memberNumeric OperationsArithmetic, Comparison, and Logical operationsArithmetic, Comparison, and Logical operations