{"record":{"id":"d006c9fbb1946ba2","repo":"pathwaycom/pathway","slug":"datetimenaive-cannot-contain-timezone-information","errorCode":null,"errorMessage":"DateTimeNaive cannot contain timezone information. Use pw.DateTimeUtc for datetimes with a timezone.","messagePattern":"DateTimeNaive cannot contain timezone information\\. Use pw\\.DateTimeUtc for datetimes with a timezone\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/pathway/internals/datetime_types.py","lineNumber":12,"sourceCode":"# Copyright © 2026 Pathway\n\nimport pandas as pd\n\n\nclass DateTimeNaive(pd.Timestamp):\n    \"\"\"Type for storing datetime without timezone information. Extends `pandas.Timestamp` type.\"\"\"\n\n    def __new__(cls, *args, **kwargs):\n        obj = super().__new__(cls, *args, **kwargs)\n        if obj.tz is not None:\n            raise ValueError(\n                \"DateTimeNaive cannot contain timezone information. Use pw.DateTimeUtc for datetimes with a timezone.\"\n            )\n        return obj\n\n\nclass DateTimeUtc(pd.Timestamp):\n    \"\"\"Type for storing datetime with default timezone. Extends `pandas.Timestamp` type.\"\"\"\n\n    def __new__(cls, *args, **kwargs):\n        obj = super().__new__(cls, *args, **kwargs)\n        if obj.tz is None:\n            raise ValueError(\n                \"DateTimeUtc must contain timezone information. Use pw.DateTimeNaive for naive datetimes.\"\n            )\n        return obj\n\n\nclass Duration(pd.Timedelta):","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/internals/datetime_types.py#L1-L30","documentation":"DateTimeNaive is Pathway's pandas.Timestamp subclass that forbids timezone awareness. Its __new__ checks obj.tz after construction and raises if the parsed value carries tzinfo, directing users to DateTimeUtc for timezone-carrying timestamps. This enforces the naive/UTC type distinction used in Pathway's temporal APIs.","triggerScenarios":"pw.DateTimeNaive(\"2024-01-01T10:00:00+02:00\"), pw.DateTimeNaive(pd.Timestamp(\"2024-01-01\", tz=\"UTC\")), or DateTimeNaive.fromtimestamp(ts, tz=...) with a tz; values landing in a DateTimeNaive-typed column from UDFs that return tz-aware timestamps.","commonSituations":"Schema declares DateTimeNaive but the source data (CSV/kafka ISO strings) includes offsets; pandas parsing with utc=True feeding Pathway; mixing naive and aware timestamps when doing as-of joins.","solutions":["If times are UTC or zone-aware, change the schema type to pw.DateTimeUtc.","Strip the timezone before ingestion: pd.to_datetime(series).dt.tz_localize(None) for the naive column.","Convert to UTC aware for DateTimeUtc: pd.to_datetime(series, utc=True)."],"exampleFix":"# before\nclass Schema(pw.Schema):\n    ts: pw.DateTimeNaive\ndf[\"ts\"] = pd.to_datetime(df[\"ts\"], utc=True)  # aware -> raises on read\n\n# after\nclass Schema(pw.Schema):\n    ts: pw.DateTimeUtc\ndf[\"ts\"] = pd.to_datetime(df[\"ts\"], utc=True)","handlingStrategy":"validation","validationCode":"def to_naive(ts: pd.Timestamp) -> pd.Timestamp:\n    return ts.tz_localize(None) if ts.tz is not None else ts\n\nassert value.tz is None before constructing pw.DateTimeNaive","typeGuard":"import pandas as pd\n\ndef is_naive_timestamp(v) -> bool:\n    return isinstance(v, pd.Timestamp) and v.tz is None","tryCatchPattern":null,"preventionTips":["Normalize pandas series with dt.tz_localize(None) before writing to DateTimeNaive columns.","Choose schema type (DateTimeNaive vs DateTimeUtc) based on whether offsets exist in the data."],"tags":["pathway","datetime","timezone","schema","type-error"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}