A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
test: normalize pandas 3.1 index reprs in table snapshots (#11541)
Kiran Gadhave6152cb9b9cc3
diff --git a/tests/_plugins/ui/_impl/tables/test_pandas_table.py b/tests/_plugins/ui/_impl/tables/test_pandas_table.pyindex e16b5edd16..91a0c85427 100644--- a/tests/_plugins/ui/_impl/tables/test_pandas_table.py+++ b/tests/_plugins/ui/_impl/tables/test_pandas_table.py@@ -43,6 +43,12 @@ def _normalize_pandas_dtypes(text: str) -> str:- interval resolutions changed accordingly- NaT/None serialization differences in to_dict() output+ Pandas 3.1 changed:+ - DatetimeIndex/TimedeltaIndex reprs wrap onto a new line before `dtype=`+ - TimedeltaIndex pads every element to the widest sub-second precision+ in the index, so `.000030` renders as `.000030000` next to a+ nanosecond-precision sibling+Normalize all to pandas 2.x representations so snapshots work across versions."""text = re.sub(r"datetime64\[\w+\]", "datetime64[ns]", text)@@ -50,6 +56,8 @@ def _normalize_pandas_dtypes(text: str) -> str:# Pandas 3.x uses "str" instead of "object" for string columns.# Normalize ["string", "str"] -> ["string", "object"] for snapshot comparisons.text = re.sub(r'\["string",\s*"str"\]', '["string", "object"]', text)+ text = re.sub(r",\n\s+(dtype=)", r", \1", text)+ text = re.sub(r"(:\d{2}\.\d{6})000(?!\d)", r"\1", text)return text