AttributeError: ‘function’ object has no attribute

Using protected keywords from the DataFrame API as column names results in a function object has no attribute error message.

Written by noopur.nigam

Last published at: May 19th, 2022


You are selecting columns from a DataFrame and you get an error message.

ERROR: AttributeError: 'function' object has no attribute '_get_object_id' in job


The DataFrame API contains a small number of protected keywords.

If a column in your DataFrame uses a protected keyword as the column name, you will get an error message.

For example, summary is a protected keyword. If you use summary as a column name, you will see the error message.

This sample code uses summary as a column name and generates the error message when run.


df=spark.createDataFrame([1,2], "int").toDF("id")
from pyspark.sql.types import StructType,StructField, StringType, IntegerType

df1 = spark.createDataFrame(
  [(10,), (11,), (13,)],
  StructType([StructField("summary", IntegerType(), True)]))

ResultDf = df1.join(df, df1.summary ==, "inner").select(,df1.summary)


You should not use DataFrame API protected keywords as column names.

If you must use protected keywords, you should use bracket based column access when selecting columns from a DataFrame. Do not use dot notation when selecting columns that use protected keywords.


ResultDf = df1.join(df, df1["summary"] ==, "inner").select(,df1["summary"])

Was this article helpful?