Facing error in creating submission file

i,m new in DS. when i want to assign this
submission[‘Loan_ID’]=test_orignanl[‘Loan_ID’]
then i get the error
TypeError: ‘method’ object is not subscriptable
why m i getting this error.

Error means that submission or test_orignanl is a function/method so it can’t be used as list/array/dataframe.

Use print() to check what is in variables

print(submission)
print(test_orignanl)

or what type they have

print( type(submission) )
print( type(test_orignanl) )

and then you will know which variable is a function/method and you which one makes problem


BTW: Similar error you can get when you treat function print() like list print['Loan_ID']

© Copyright 2013-2019 Analytics Vidhya