I am trying to create schema for below mentioned type of data, it's a list of dictionaries for using it with udf but I am getting the error mentioned in below.
Unexpected tuple %r with StructType
[{'cumulativeDefaultbalance': 0, 'loanId': 13131, 'cumulativeEndingBalance': 4877.9918745262694, 'cumulativeContractpaymentw': 263.67479214039736, 'month': 1, 'cumulativeInterestpayment': 141.66666666666666, 'cumulativePrincipalpayment': 122.00812547373067, 'cumulativeAdjbeginingbal': 5000, 'cumulativePrepaymentamt': 40.315417142065087}]
Below is the schema object that I am building
schema = StructType([
StructField('cumulativeAdjbeginingbal', FloatType(), False),
StructField('cumulativeEndingBalance', FloatType(), False),
StructField('cumulativeContractpaymentw', FloatType(), False),
StructField('cumulativeInterestpayment', FloatType(), False),
StructField('cumulativePrincipalpayment', FloatType(), False),
StructField('cumulativePrepaymentamt', FloatType(), False),
StructField('cumulativeDefaultbalance', FloatType(), False)
])
Can anyone tell what's making my code fail?