Trying to extract records with latest date for distinct values of column A and column B (below)
Ideal Result:
Current Solution:
from pyspark.sql import functions as f
test = df.groupBy(df['A'], df['B']).agg(f.first(df['C']), f.first(df['D']), f.max(df['E']))
Any loopholes to look for or suggestiones to optimize the above ?

