File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -94,8 +94,10 @@ def normalize_df(self, df: pd.DataFrame) -> pd.DataFrame:
9494 """
9595 new_columns = {col : req .default for (col , req ) in self ._requirements .items () if col not in df .columns }
9696 df = df .assign (** new_columns )
97- # Apply dtype conversions to ensure compatibility with pandas 3's stricter type checking
98- # This is especially important for columns that may contain NaN values but need to be strings
97+ # Apply dtype conversions to ensure compatibility with pandas 3's stricter type checking.
98+ # This is especially important for columns that may contain NaN values but need to be strings.
99+ # We only convert columns with specific dtype requirements (e.g., "str", "float64").
100+ # Columns with dtype="object" are skipped because "object" is pandas' flexible catch-all type.
99101 dtype_conversions = {}
100102 for col , req in self ._requirements .items ():
101103 if col in df .columns and req .dtype != "object" :
Original file line number Diff line number Diff line change @@ -78,11 +78,14 @@ def _get_annotation_str(annotation: Union[str, type]) -> str:
7878
7979def _annotation_is_pandas_series (annotation ) -> bool :
8080 # Support both pandas 2.x ("pandas.core.series.Series") and pandas 3.x ("pandas.Series")
81+ # We explicitly list both paths to ensure cross-version compatibility:
82+ # - UDFs written with pandas 2.x annotations should work in pandas 3.x environments
83+ # - UDFs written with pandas 3.x annotations should work in pandas 2.x environments
8184 return annotation in {
8285 pandas .Series ,
83- _get_annotation_str (pandas .Series ),
84- "pandas.core.series.Series" , # Legacy pandas 2.x path
85- "pandas.Series" , # pandas 3.x path
86+ _get_annotation_str (pandas .Series ), # Current pandas version's path
87+ "pandas.core.series.Series" , # Explicit pandas 2.x path for cross-version support
88+ "pandas.Series" , # Explicit pandas 3.x path for cross-version support
8689 }
8790
8891
You can’t perform that action at this time.
0 commit comments