Sep-07-2023, 07:12 AM
Try change to this.
By using
This ensures that are working on a new DataFrame rather than inadvertently modifying the original one.
SettingWithCopyWarning
is generated by pandas when you are modifying a DataFrame that is actually a view of another DataFrameBy using
.copy()
to make a copy of the DataFrame before modifying it,should avoid the SettingWithCopyWarning
.This ensures that are working on a new DataFrame rather than inadvertently modifying the original one.
# Make supplier table. Supplier table contains rows from product_table # where one of the words in the description matches a supplier code. supplier_table = product_table[["Description"]].copy() supplier_table["Product"] = supplier_table["Description"].map(find_supplier) supplier_table = supplier_table[~supplier_table["Product"].isna()] supplier_table = supplier_table[["Product", "Description"]] print(supplier_table)