abhiips07 commented on code in PR #51006: URL: https://github.com/apache/spark/pull/51006#discussion_r2106627924
########## python/pyspark/pandas/strings.py: ########## @@ -2031,7 +2031,13 @@ def pudf(s: pd.Series) -> pd.Series: if expand: psdf = psser.to_frame() scol = psdf._internal.data_spark_columns[0] - spark_columns = [scol[i].alias(str(i)) for i in range(n + 1)] + + if ps.get_option("compute.ansi_mode_support"): + spark_columns = [ + F.try_element_at(scol, F.lit(i + 1)).alias(str(i)) for i in range(n + 1) Review Comment: can we try to calculate f.lit(i+1) outside loop? since this might avoid function calls and object creation during loop execution ``` literals = [F.lit(i + 1) for i in range(n + 1)] spark_columns = [F.try_element_at(scol, lit).alias(str(i)) for i, lit in enumerate(literals)] ``` -- 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