I have a list lists=[0,1,2,3,5,6,7]
. Order is not sequential. I have a pyspark dataframe with 9 columns.
+-------------------+--------+--------+--------+--------+--------+--------+---------------+-----+----+
| date|ftt (°c)|rtt (°c)|fbt (°c)|rbt (°c)|fmt (°c)|rmt (°c)|fmhhumidityunit|index|Diff|
+-------------------+--------+--------+--------+--------+--------+--------+---------------+-----+----+
|2019-02-01 05:29:47| NaN| NaN| NaN| NaN| NaN| NaN| NaN| 0| NaN|
|2019-02-01 05:29:17| NaN| NaN| NaN| NaN| NaN| NaN| NaN| 1| NaN |
I need to add my lists as a column to my existing dataframe. My lists is not in order so iam not able to use udf. Is there a way to do it?.Please help me I want it to be like this
+-------------------+--------+--------+--------+--------+--------+--------+---------------+-----+----+------+
| date|ftt (°c)|rtt (°c)|fbt (°c)|rbt (°c)|fmt (°c)|rmt (°c)|fmhhumidityunit|index|Diff|lists |
+-------------------+--------+--------+--------+--------+--------+--------+---------------+-----+----+-------+
|2019-02-01 05:29:47| NaN| NaN| NaN| NaN| NaN| NaN| NaN| 0| NaN|0 |
|2019-02-01 05:29:17| NaN| NaN| NaN| NaN| NaN| NaN| NaN| 1| NaN |1 |