0

How can I delete this number in my "Kecamatan" Columns

enter image description here

2
  • Did my answer help you? Commented Feb 21, 2022 at 14:38
  • Please do not link or embed external images of source code or data. Images make it difficult to efficiently assist you as they cannot be copied and offer poor usability as they cannot be searched. See: Why not upload images of code/errors when asking a question? If you need assistance formatting a small sample of your DataFrame as a copyable piece of code for SO see How to make good reproducible pandas examples. Commented Mar 2, 2022 at 4:05

1 Answer 1

1

You can replace the leading digits and dot using regular expression, as follows:

import pandas as pd

df = pd.DataFrame({
    'Kecamatan': ['010. Donomulyo', '020. Kalipare', '030. Pagak', '040. Bankur']
})

df['Kecamatan'] = df['Kecamatan'].str.replace(r'\A[0-9. ]+', '', regex=True)

print(df)
>>>df
   Kecamatan
0  Donomulyo
1   Kalipare
2      Pagak
3     Bankur
Sign up to request clarification or add additional context in comments.

Comments

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.