I have a dataset where the part numbers are categorized into subinventories.
I want to replace some values, e.g. "COIL 8" with just "COIL", so I can group similar parts together. The data is an object in the dataframe. I've stripped out leading and trailing spaces. I've also copied the value from the dataframe into the code to make sure the number of spaces between COIL and 8 is the same. Changing the Subinventory to "COIL_8" is not an option...that's how I receive the data. I only need to change the values in the "Subinventory" column but there isn't an issue with code applying to the entire dataframe.
I've looked in documentation and tried several of the options but not getting something correct as none of the values are replaced.
elemental_inv_df.replace({'Subinventory': 'COIL 8'}, {'Subinventory': 'COIL'}, regex=True, inplace = True)
elemental_inv_df = elemental_inv_df.replace("FAB 1", "FAB")
elemental_inv_df = elemental_inv_df.replace(regex={'COIL 33': 'COIL'})
elemental_inv_df = elemental_inv_df.replace(['DECOIL 1'], 'DECOIL')
elemental_inv_df
