0
               1          2
0    ADRC-111-01    ADRC111
1  ADRC-11955-01  ADRC11955
2  ADRC-18133-01  ADRC18133
3    SWAN0023-03   SWAN0023

In Column 1, I wish to get rid of the first - sign, regardless of how many are in the the cell. There are one or two - in each entry.

Desired output:

              1          2
0    ADRC111-01    ADRC111
1  ADRC11955-01  ADRC11955
2  ADRC18133-01  ADRC18133
3    SWAN002303   SWAN0023
0

1 Answer 1

2

Use .str.replace with n=1:

df['1'] = df['1'].str.replace('-', '', n=1)

Output:

>>> df
              1          2
0    ADRC111-01    ADRC111
1  ADRC11955-01  ADRC11955
2  ADRC18133-01  ADRC18133
3    SWAN002303   SWAN0023
Sign up to request clarification or add additional context in comments.

1 Comment

thank you so much! worked!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.