-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update data_loader with the error message and add data_preprocessing.…
…py module for removing missing values
- Loading branch information
1 parent
82eb994
commit a34d653
Showing
2 changed files
with
23 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import pandas as pd | ||
|
||
def remove_and_check_missing(df): | ||
""" | ||
Remove rows with missing values in 'CustomerID' and 'Description' columns. | ||
Then, check if there are any missing values left in the dataframe. | ||
If there are, raise a MissingValueError. | ||
""" | ||
|
||
# Remove rows with missing values in 'CustomerID' and 'Description' | ||
df = df.dropna(subset=['CustomerID', 'Description']) | ||
|
||
# Check if there are any missing values left | ||
if df.isna().sum().sum() != 0: | ||
missing_count = df.isna().sum().sum() | ||
message = f"There are {missing_count} missing values left in the dataframe." | ||
print(message) | ||
raise ValueError(message) | ||
|
||
return df | ||
|
||
|