{"record":{"id":"06a36309b8c68fdb","repo":"pandas-dev/pandas","slug":"of-the-four-parameters-start-end-periods-and-f","errorCode":null,"errorMessage":"Of the four parameters: start, end, periods, and freq, exactly three must be specified","messagePattern":"Of the four parameters: start, end, periods, and freq, exactly three must be specified","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"pandas/core/arrays/datetimes.py","lineNumber":409,"sourceCode":"        cls,\n        start,\n        end,\n        periods: int | None,\n        freq,\n        tz=None,\n        normalize: bool = False,\n        ambiguous: TimeAmbiguous = \"raise\",\n        nonexistent: TimeNonexistent = \"raise\",\n        inclusive: IntervalClosedType = \"both\",\n        *,\n        unit: TimeUnit = \"ns\",\n    ) -> Self:\n        periods = dtl.validate_periods(periods)\n        if freq is None and any(x is None for x in [periods, start, end]):\n            raise ValueError(\"Must provide freq argument if no data is supplied\")\n\n        if com.count_not_none(start, end, periods, freq) != 3:\n            raise ValueError(\n                \"Of the four parameters: start, end, periods, \"\n                \"and freq, exactly three must be specified\"\n            )\n        freq = to_offset(freq)\n\n        if start is not None:\n            start = Timestamp(start)\n\n        if end is not None:\n            end = Timestamp(end)\n\n        if start is NaT or end is NaT:\n            raise ValueError(\"Neither `start` nor `end` can be NaT\")\n\n        if unit is not None:\n            if unit not in [\"s\", \"ms\", \"us\", \"ns\"]:\n                raise ValueError(\"'unit' must be one of 's', 'ms', 'us', 'ns'\")\n        else:","sourceCodeStart":391,"sourceCodeEnd":427,"githubUrl":"https://github.com/pandas-dev/pandas/blob/71959b8cb9b2459c16e14b34f28b178ccfe14735/pandas/core/arrays/datetimes.py#L391-L427","documentation":"Raised in _generate_range when the count of non-None values among start, end, periods, freq is not exactly three. With all four, the system is over-determined and the constraints may contradict; with fewer than three it is under-determined. Exactly one of start/end/periods is the unknown to solve for.","triggerScenarios":"pd.date_range(start, end, periods, freq) all four set; pd.date_range(start, end) with neither periods nor freq (only two); pd.date_range(start) with only start.","commonSituations":"Passing all four 'just to be safe'. Migrating from an older call that inferred the missing one. Defaults of None on periods/freq interacting with provided start/end.","solutions":["Leave exactly one of the four unset (the one you want computed): start+end+freq -> periods; start+periods+freq -> end; end+periods+freq -> start.","If you supplied all four by mistake, drop the redundant one.","For a single timestamp, use pd.Timestamp or pd.DatetimeIndex([start]) rather than date_range."],"exampleFix":"# before (over-specified)\npd.date_range('2020-01-01', '2020-01-05', periods=5, freq='D')\n\n# after (let pandas derive periods)\npd.date_range('2020-01-01', '2020-01-05', freq='D')","handlingStrategy":"validation","validationCode":"provided = sum(x is not None for x in (start, end, periods, freq))\nif provided != 3:\n    raise ValueError(f'exactly 3 of start/end/periods/freq required, got {provided}')","typeGuard":null,"tryCatchPattern":"try:\n    pd.date_range(start, end, periods, freq)\nexcept ValueError as e:\n    if 'exactly three must be specified' in str(e):\n        # drop the over-specified or under-specified param\n        pd.date_range(start, end, freq='D')\n    else: raise","preventionTips":["Decide which one of the four to derive and leave it unset by design.","Add a unit test asserting your date_range calls pass exactly three."],"tags":["date-range","constructor","validation"],"analyzedSha":"71959b8cb9b2459c16e14b34f28b178ccfe14735","analyzedAt":"2026-08-07T01:30:20.476Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}