I am trying to store a column of pyspark dataframe into python list using collect function. e.g.
list_a = [row[column_name] for row in dataset_name.collect()]
but this is very slow process and takes more than 10 seconds for a dataframe of 3 columns and 27 rows.
is there a faster way to do so?
I tried caching the data before this step . With this step, the above query is being executed in 2 seconds but cache step itself is taking around 7-8 seconds so my purpose of reducing time is not full filled.
And my code is such that i need to rebuild the dataframe everytime before this step so need to do cache again so this step(caching the dataframe) is not helping a lot in time reduction.
Thanks in advance!