petern48 commented on code in PR #51475:
URL: https://github.com/apache/spark/pull/51475#discussion_r2223081908


##########
python/pyspark/pandas/typedef/typehints.py:
##########
@@ -362,8 +362,9 @@ def infer_pd_series_spark_type(
     if dtype == np.dtype("object"):
         if len(pser) == 0 or pser.isnull().all():
             return types.NullType()
-        elif hasattr(pser.iloc[0], "__UDT__"):
-            return pser.iloc[0].__UDT__
+        first_idx = pser.first_valid_index()
+        if first_idx is not None and hasattr(pser.loc[first_idx], "__UDT__"):
+            return pser.loc[first_idx].__UDT__

Review Comment:
   Nice! Accepted the change and all tests passing



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to