Python Forum
How to split at specified delimiter
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to split at specified delimiter
#6
(Dec-27-2018, 02:41 PM)SriRajesh Wrote: but it does not print give any output.
He do it from interactive shell.
Like this without:
import re

regex = re.compile(r"\d*E\d*")
match = regex.search('VN009K30E6T00')
aa = match.group()
print(aa)
SriRajesh Wrote:I have below DataFrame:
When using pandas,you should not take it out of DataFrame and use regex.
pandas has build in regex(str) to deal with DataFrame.
Example:
import pandas as pd

df = pd.DataFrame(
    [['VA004L200E2T99',77, 999],
     ['VG002K500E4T99',55, 100],
     ['VN009K30E6T00',33, 9]],
     columns=['val','foo', 'bar']
)

df['val'] = df['val'].str.extract(r'(\d*E\d*)', expand=False)
print(df)
Output:
val foo bar 0 200E2 77 999 1 500E4 55 100 2 30E6 33 9
Reply


Messages In This Thread
How to split at specified delimiter - by SriRajesh - Dec-27-2018, 01:00 PM
RE: How to split at specified delimiter - by snippsat - Dec-27-2018, 03:43 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  python Read each xlsx file and write it into csv with pipe delimiter mg24 4 1,850 Nov-09-2023, 10:56 AM
Last Post: mg24
  Context-sensitive delimiter ZZTurn 9 1,740 May-16-2023, 07:31 AM
Last Post: Gribouillis
  Read csv file with inconsistent delimiter gracenz 2 1,370 Mar-27-2023, 08:59 PM
Last Post: deanhystad
  Delimiter issue with a CSV file jehoshua 1 1,432 Apr-19-2022, 01:28 AM
Last Post: jehoshua
  How to create new line '/n' at each delimiter in a string? MikeAW2010 3 3,008 Dec-15-2020, 05:21 PM
Last Post: snippsat
  copy content of text file with three delimiter into excel sheet vinaykumar 0 2,449 Jul-12-2020, 01:27 PM
Last Post: vinaykumar
  How to print string multiple times separated by delimiter Mekala 1 2,024 May-23-2020, 09:21 AM
Last Post: Yoriz
  How to split string after delimiter SriRajesh 1 2,198 Sep-11-2019, 11:25 AM
Last Post: metulburr
  Merge 2 lines with delimiter Buddhism 9 4,700 May-05-2019, 02:43 AM
Last Post: Buddhism
  Parsing text list to csv using delimiter discarding non-interesting data murdock72 3 4,370 Feb-22-2017, 06:38 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020