From 6b8c8ea67fe19d31508c4922cee5246b2ef60d69 Mon Sep 17 00:00:00 2001 From: Ashish Kamboj Date: Sat, 16 Jul 2022 16:45:13 +0530 Subject: [PATCH] Updated fill_na_rows function with method='linear' and limit_direction='both' Changed interpolate method to 'linear' and limit_direction to 'both' As with the method='pad' if index 0 value is NaN then this method won't will the index 0 value (it will remain NaN after interpolation also). Also with method='pad' we can't have limit_direction='backward' It's better to choose method='linear' and limit_direction='both' (because there will be chances that first and last index values can be NaN, it will be easily interpolated if limit_direction='both') --- quickda/clean_data.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quickda/clean_data.py b/quickda/clean_data.py index 7c47cd1fe..5abd5dd32 100644 --- a/quickda/clean_data.py +++ b/quickda/clean_data.py @@ -42,7 +42,7 @@ def fill_na_rows(data): # Retrieve the list of columns having nulls and interpolate for each column na_columns = df.columns[df.isna().any()].tolist() for column in na_columns: - df[column] = df[column].interpolate(method='pad', limit_direction='forward') + df[column] = df[column].interpolate(method='linear', limit_direction='both') return df @@ -185,4 +185,4 @@ def clean(data, method="default", columns=[], dtype="numeric", to_replace="", va except Exception as e: print(e) - return data \ No newline at end of file + return data