Skip to content

Check boundary undefined with non-default close parameter for date_range #23198

@Adirio

Description

@Adirio

Code Sample

import pandas as pd
print(pd.date_range(start="2018-10-17", periods=7, closed="left"))
print(pd.date_range(start="2018-10-17", periods=7, closed="right"))
print(pd.date_range(end="2018-10-17", periods=7, closed="left"))
print(pd.date_range(end="2018-10-17", periods=7, closed="right"))

Problem description

There is a check in the code that should not allow this cases. It raises a ValueError. The ifcondition is bugged and thus this check is not being processed. This was found while investigating #23176.

Note: this issue is not debating wether allowing or disallowing closed differents to None for only partially bounded date_rangees (understanding partially bounded as only one of start and end provided). It is just pointing out that the current code is skipping a check.

Expected Output

1:

ValueError("Closed has to be None if not both of startand end are defined")

2:

ValueError("Closed has to be None if not both of startand end are defined")

3:

ValueError("Closed has to be None if not both of startand end are defined")

4:

ValueError("Closed has to be None if not both of startand end are defined")

Output of pd.show_versions()

python: 3.6.4.final.0

pandas: 0.23.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDatetimeDatetime data dtypeError ReportingIncorrect or improved errors from pandas

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions