I'm trying to elaborate three csv file and create only one file merging the useful data.
Now, I'm stuck on this problem:
I have two columns (SUFFIX and COD_METEL), with 1.5 Millions of rows, that I need to elaborate and create another column containing the results.
SUFFIX COD_METEL
0 CBR CBR8901027
1 CBR CBR8901028
2 CBR CBR8904001
3 CBR CBR8904002
4 CBR CBR8904008
5 CBR CBR8904027
6 CBR CBR8904039
7 THO THO96666290
8 THO THO96666294
9 THO THO96666298
10 THO THO96666302
11 THO THO96666322
12 THO THO96666326
13 ZV ZV111900NI
14 ZV ZV111910NI
15 ZX ZX2021.AC
16 ZX ZX2021.AC
17 ZX ZX6066.AC
18 ZX ZX6111.AC
19 ZX ZX6111.AC
20 ZX ZX6380.AC
21 ZX ZX9030
22 ZX ZX9030
23 ZX ZX9030
24 ZZ ZZ00012565
Here I need to "subtract" the SUFFIX value to the COD_METEL, like this:
df["RESULT"] = df["COD_METEL"] - df["SUFFIX"]
SUFFIX COD_METEL RESULT
0 CBR CBR8901027 8901027
1 CBR CBR8901028 8901028
2 CBR CBR8904001 8904001
I know that is not possible to use the "-" operator, so I'm asking you some tips to figure out this problem, and replace all the value in a faster way.
I have already tried to do some tests:
replaceList = list(set(df["SUFFIX"]))
for to_replace in replaceList:
df["RESULT"] = df["COD_METEL"].str.replace(to_replace,"")