a1 a2 a3 v_Zones l_season inlier
58 0 21393.0 -34.0247 ... 7_VII 163 True
999 0 61028.0 -31.9992 ... 44_VI 135 True
15 0 20296.0 -30.1956 ... 4_Vn 226 True
746 0 55236.0 -33.1020 ... 2_VI 174 True
1000 0 61032.0 -32.1942 ... 20_Vc 158 True
In the dataframe above, I want to replace the strings in v_Zones column based on following logic:
- Any string ending in
Vnshould end withVIinstead - Any string ending in
Vcshould end withVinstead
I tried using pandas replace command, but not sure how to partially replace a string based on regex. Result should look like this:
a1 a2 a3 v_Zones l_season inlier
58 0 21393.0 -34.0247 ... 7_VII 163 True
999 0 61028.0 -31.9992 ... 44_VI 135 True
15 0 20296.0 -30.1956 ... 4_VI 226 True
746 0 55236.0 -33.1020 ... 2_VI 174 True
1000 0 61032.0 -32.1942 ... 20_V 158 True