0

I have a dataframe df. In which we have order_date I need to scan through the years from the date column (using split) and compare it to end year if it matches then assign it to @i and then increase the end year I have added a df to show the putput expected

df

df:

    df[order_date] = 1/2/2020
    df[st_yr] = 2020
    df[ed_yr] = df[st_yr] + 1

    do i = 1 to 5
    if df.withColumn("order_date", split(col("order_date"), "/").getItem(2)) = df[ed_yr]
        df[st_yr] = i;
        df[ed_yr] = df[ed_yr] + 1
    end
Eden T
  • 57
  • 1
  • 8
  • 2
    Please have a look at: - [How to make good reproducible Apache Spark examples](https://stackoverflow.com/questions/48427185/how-to-make-good-reproducible-apache-spark-examples) – anky May 09 '20 at 16:18
  • can u check now – Eden T May 12 '20 at 13:41

0 Answers0