I am trying to extract numeric string from text using python - example : "大田区大森北3−24−27ルミエールN103 " I only want '3-24-27' from a column in df. I tried this but the error says invalid syntax. I am now working with Japanese script but I need this for other languages as well. I am new to python and request some help - Thanks.
2 Answers
Using str.extract
Ex:
import pandas as pd
df = pd.DataFrame({"a": [ "大田区大森北3−24−27ルミエールN103"]})
print( df["a"].str.extract(r"(\d+−\d+−\d+)") )
Output:
0 3−24−27
Name: a, dtype: object
- Note: I have used
−not the minus symbol in keyboard(-)
1 Comment
Rakesh
Please accept ans if it solved your problem(tick symbol near the ans) Thanks
# -*- coding: utf-8 -*-to the top of your file before imports. Try putting your full code so we could figure out the answer