So I have a Dataframe where I want to replace every value with a new string.
(Usually I would just do df["col1"] = "string", however I need to use loc before, which creates a copy and does not manipulate the series in place)
So currently I have a df like this
df = pd.DataFrame({'A': ['aaaa', 'b', 'c', 'd', 'e']})
And when I replace it with the replace function
df.A.replace(".*","test", regex= True, inplace= True)
I get something like this
However what I want is something like this:
Why does it give me "test" twice. And how can I fix it?
Edit: So to show you what the actual problem was. I will give you this example, to show you the whole picture. Basically I have this two things
df = pd.DataFrame({'A': ['aaaa', 'bbbb', 'c', 'd', 'e']})
replace_list = ["aa","bb"]
Now I want the df to replace every entry where an item in the list is present with the item in the list. So the df would look like this: