0

I have a dataframe:

df112 = pd.DataFrame({'A': ['**MDHC1235 Variance colinear', '**HINN0165 Paris Tower [HAQ] Relay Fashion', 'RJV Rust Falcon Contrast[HAQ] R/T (HQA)', 'Hulk Premiere A764FAR Quota 2112(HQA)'], 
                    'B': ['Italian Paste', 'US-AMBAS Contact Insured Person', '**ABDH1654 John and Jack', 'Romania (HQ)']})

I am using the below code to get spaces between any text and (

df112['A'] = df112['A'].str.replace("(\S)\(", "\1 (", regex=True)
df112['A'] = df112['A'].str.replace("(\S)\[", "\1 [", regex=True)

I am getting output like :

    A                                                        B
0   **MDHC1235 Variance colinear                        Italian Paste
1   **HINN0165 Paris Tower [HAQ] Relay Fashion          US-AMBAS Contact Insured Person
2   RJV Rust Falcon Contras [HAQ] R/T (HQA)             **ABDH1654 John and Jack
3   Hulk Premiere A764FAR Quota 211 (HQA)               Romania (HQ)

I don't understand why 't' in word Contrast and second '2' in 2112 is gone

Am I doing something wrong?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Vas
  • 918
  • 1
  • 6
  • 19

0 Answers0