Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2021 03:48 AM
I was able to find the issue. it was happening because, python doesn't understand spark's decimal data type so, spark treats it as object and that's why rest of the python code was taking so much of time.
And after explicitly type casting it its even faster 😎 😃 . thanks guys for input.
here is the code, i am using to handle all the decimal column, Let us know if there is a better way :
def fix_decimal_type(df):
decimal_columns = list(filter(None,[(col_ if "decimal" in unseen_df_sp.schema[col_].dataType.simpleString()else '') for col_ in df.columns]))
for col_ in decimal_columns:
df=df.withColumn(col_, col(col_).cast(DoubleType()))
return df