0

I have imported a csv file as a DataFrame. It has two columns, with the first line being the column name:

To Group        Group To
 A Name          A Group
 ...             ....

Later I have to make a new column called "Grouping" in which it is basically the "Name" column but with some names replaced with the following method.

filtered["Grouping"] = filtered["Name"].replace(list(self.map_group["To Group"]), list(self.map_group["Group To"]))

This method seems to work very well, except for two of my rows. Those row's "Grouping" column is the same as their "Name". I have tried replacing my "name" strings in the csv files, using notepad and Excel to no use. I have also printed

print("a name" in list(self.map_group["To Group"]))

And that equals true. It doesn't seem like I have made a spelling mistake. I have also added regex = True to the method with no changes as well.

Any help will be appreciated!

0 Answers0