Home > Net >  TypeError: 'DataFrame' object is not callable left join databricks
TypeError: 'DataFrame' object is not callable left join databricks

Time:11-12

i am trying to left join two data frames by coding as below:

billing_classDF:

icp billing_class
0   0000033830DE8D0 RESI
1   0000044100DE8F8 RESI
2   0000033883DE6A2 RESI

alpeDF:

    Invoice No  Site    Load Group  Description Charge Month    From    To  Factor Description  Factor 1    Divisor 2   Factor 3    Factor 4    Amount Exclusive GST    Reversed Line
0   8888    0006472848AL9C1 015HCA  Distribution Fixed Charge   Oct-21  1/10/2021   31/10/2021  None    31  None    None    31  44.76   None
1   8888    0004943007ALFEB 015HCA  Distribution Fixed Charge   Oct-21  1/10/2021   31/10/2021  None    31  None    None    31  44.76   None
2   8888    0005350255AL270 LOWLCA  Additional LOW Variable Distribution Charge Oct-21  1/10/2021   31/10/2021  None    561 None    None    None    26.2    None

Code

alpe_billing_class=alpeDF.join(billing_classDF, alpeDF('Site')==billing_classDF('icp'), 'left')

I got error message:

TypeError: 'DataFrame' object is not callable

CodePudding user response:

rename "Site" to "icp"

alpeDF=alpeDF.withColumnRenamed('Site','icp')
billing_class_alpe=alpe.join(billing_class, ['icp'],'left')

and it works. Cheers :D

CodePudding user response:

You should use square brackets instead of normal brackets:

alpeDF.join(billing_classDF, alpeDF['Site']==billing_classDF['icp'], 'left')
  • Related