• Post author:
  • Post category:PySpark
  • Post last modified:March 27, 2024
  • Reading time:3 mins read
You are currently viewing PySpark – TypeError: Column is not iterable

Problem 1: When I try to add a month to the data column with a value from another column I am getting a PySpark error TypeError: Column is not iterable.

from pyspark.sql.functions import add_months

Get’s below PySpark Error during run-time.

TypeError: Column is not iterable

Solution for TypeError: Column is not iterable

PySpark add_months() function takes the first argument as a column and the second argument is a literal value. if you try to use Column type for the second argument you get “TypeError: Column is not iterable”. In order to fix this use expr() function as shown below.