Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ENH: arithmetic between DatetimeArray and list #62353

Open
Labels
Enhancement Needs TriageIssue that has not been reviewed by a pandas team member Numeric OperationsArithmetic, Comparison, and Logical operations
@cmp0xff

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

No one assigned

    Labels

    Enhancement Needs TriageIssue that has not been reviewed by a pandas team member Numeric OperationsArithmetic, Comparison, and Logical operations

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /